Sublime Forum

View.classify() returns 4096

#1

Hello everyone,

While developing my plugin I came across this interesting and perhaps buggy return value of the method classify within the view class. Take this code for example:

class Type;

int operator+(int, const Type&) {
    return 5;
}

Invoking view.classify(point) where point is at the end of the name operator+ (just before the opening brace) returns an undocumented value of 4096.

I expected the return value would say that this point fits sublime.CLASS_WORD_END or sublime.CLASS_PUNCTUATION_END but alas, I got an astronomous number instead :smile:

Am I doing something wrong here? Or is it a just wierd bug?

0 Likes

#2

That’s a number being used as a bitfield.

To find out of it’s a CLASS_WORD_END, you use bitwise arithmetic:

is_word_end = view.classify(point) & sublime.CLASS_WORD_END
2 Likes

#3

Alright, that’s what I’m doing. But the result is false with any of the available classes.

Hence my question: Is it possible that the return value of classify() won’t match any of the classes (by performing classify(point) & Sublime.CLASS_...)? And if it is possible, why is the value equals to 4096 and not 0?

(The value 4096 hints on an additional sublime classes that are not documented)

Also, doesn’t my example from my first post describe a position that should fit sublime.CLASS_WORD_END or sublime.CLASS_PUNCTUATION_END?

0 Likes