Sublime Forum

Symbols less than 3 characters are silently excluded from Goto Symbol in Project (even though they show up in Goto Symbol)?

#1

This is just my theory, I don’t know if it’s true, but it would predict just behavior I’ve observed

I’ve defined a custom syntax, with a custom .tmPreferences file specifying certain captured groups to both showInSymbolList and showInIndexedSymbolList.

However I realized while using it that if a symbol has only 2 characters, then even though it WILL show up in Ctrl+R, it will NOT show up in Ctrl+Shift+R, and that lengthening the symbol by 1 character (e.g. change it from “fn” to “fn1”) makes all the difference!

I’ve used “show scope” and verified that both “fn” and “fn1” have the same scope. (Plus, they BOTH show up in GoTo Symbol; it’s just that one shows up in the project-wide symbol list, the other doesn’t)

This could be because I messed up somewhere else but before I investigate, I just want to ask a quick question first, whether this is indeed the case (that Sublime automatically exclude symbols from project-wide index if they are too short, less than 3 chars long)?

I’ve done some searches and nothing shows up.

0 Likes

#2

yes, you are correct

1 Like

#3
0 Likes

#4

Thanks for the reference. I guess can definitely work around it for my personal purposes, since it’s a custom syntax for personal note taking, although I can imagine it cause surprise for those who program in terse languages!

0 Likes

#5

Update: I just followed the link at the bottom of the github page, and tried to modify symbol.py to comment out the bit

if len(symbol.strip()) < 3:
    return []

Made no difference however.
I guess it’s possible that the 3-char limit is hard coded in the API (window.lookup_symbol_in_index()) and the conditional here is just a nod to that

0 Likes