I’m having trouble working out what the exact rules are for the region returned from view.extract_scope. I’m working on better scopes for the Lua grammar, but some of the behaviour is puzzling to me.
e.g. Here’s the visual scope for the comment delimiter, plus the text scope description. The cursor is on ‘–’:
source.lua comment.line.double-dash.lua punctuation.definition.comment.lua
http://img.skitch.com/20120225-gd5tc8et7ehahtgaec6ar4g3ps.png
This what I would expect. The innermost scope at the cursor is the comment delimiter. As you move to the right where nothing is scoped, the visual scope moves out to match the entire comment. Again, I expect this because it is the now the innermost scope since I never scoped the comment text.
source.lua comment.line.double-dash.lua
http://img.skitch.com/20120225-nrmuutmgu73tk77sg6g3n14uc4.png
Now here’s the strange one. When I highlight the word ‘function’, it matches the entire function’s scope, not the keyword ‘function’ itself. Note that the keyword is the innermost scope.
source.lua meta.function.lua keyword.control.lua
http://img.skitch.com/20120225-np8euychuun72rbc1c6suyp4j2.png
So why does this match the scope ‘meta.function.lua’ rather than ‘keyword.control.lua’?
On a related note, it would be awesome to be able to choose the scope level in extract_scope. This would allow me to visualize all scopes for a particular token. Needless to say this would be very handy when working on language grammars.