Sublime Forum

Goto definition not working for Julia `myfunc!()`

#1

Hello,

The goto feature in Sublime Text is currently not working for certain JuliaLang functions. Specifically, functions where arguments are modified, which is denoted by appending the function name with an exclamation mark (!). I hope this can be fixed easily!

Thank you,

Charles

0 Likes

#2

Are you using the Julia plugin by JuliaEditorSupport? If so, file a bug report on their GitHub repository.

0 Likes

#3

I am, actually. Iā€™ll file a bug on their repo. Thank you!

0 Likes

#4

Perhaps Iā€™m unclear how Sublime Text works, but the Julia plugin that @michaelblyons suggested is for syntax highlighting. The goto feature is still not working correctly/consistently on Windows and Mac OS.

I just want to be sure that this is a problem with the Julia plugin, and not sublime text, before continuing with adding issues to their repo.

Thank you!

0 Likes

#5

Basically a syntax definition such as Julia.sublime-syntax defines certain scopes for symbols which are to index. By default functions whose name is scoped as entity.name.function are added to the symbol database (index) by default. If the mouse hovers a word myfunc which exists in the index, the Goto Definition Popup is displayed with a list of links of all positions mydoc with the scope entity.name.function exists.

A package can define any kind of symbols to be added to the index by creating a Symbol List - myfunc.tmPreferences (see: Julia/Symbol Index.tmPreferences)

You should not expect high precision context sensitive goto definition lists. The popup displays any word which matches the name and scope. This is what you might need a language server for, which has a much better understanding of the code structure.

3 Likes

#6

Thanks for the response! Iā€™m not sure that I get what you mean by ā€œYou should not expect high precision context sensitive goto definition listsā€.

Everything works as expected for ordinary functions without the (!), so I think that this is just an issue with Julia-Sublime package.

Thanks again for the feedback!

0 Likes

#7

It means that sometimes for some languages, it can show you things which should not be there. But other times, you may be very lucky, as you seemed to be right now, and it only shows you right things.

0 Likes

#8

does it help if you select myfunc! before pressing F12?

0 Likes

#9

I installed Julia and tried creating a function with the name myfunc!(). As stated in the packageā€™s issue it is recognized very perfectly. So maybe you could post a snippet of code of where your function is defined or better the whole file if possible. Maybe the syntax definition is not able to identify the myfunc! as entity.name.function for some reason.

0 Likes

#10

Sure, hereā€™s a MWE:

function test_a!(x::Int)
print("Go to this function doesn't work")
end

# selecting "test_a!" and "test_a" does NOT give me the option to goto the test_a! function
test_a!(x)

function test_b(x::Int)
print("Go to this function works")
end

# selecting "test_b" DOES give me the option to goto the test_b function
test_b(x)

Iā€™m on Mac OS, High Sierra, 10.13.6.

Packages installed on ST3, version 3.3.1, build 3176:

  • Alignment
  • Fortran
  • Julia
  • LaTeXTools
  • Package Control
  • PackageResourceViewer
  • PlainTasks
  • Text Pastry
  • TrailingSpaces

Hope that helps others. But again, I imagine that this is an issue with the Julia-Sublime package, as the answers indicate.

0 Likes

#11

Hooray for MWEs! I do not have your exact set of packages or OS/ST3 version (Mojave, ST build 3184), but the Julia package successfully identifies the function definition from its line 6 usage on my system.

Things you could try:

  1. Add all your other downloaded packages to the ignored_packages list in ST Settings. If it works, re-enable them one by one to find the culprit.
  2. Examine the scope of the ! and a non-! character each in the errant function def and call to see if thereā€™s anything untoward.
1 Like