hansec / vscode-fortran-ls

Fortran IntelliSense for Visual Studio Code
MIT License
37 stars 7 forks source link

Opening separate file when going to definition #6

Closed duhd1993 closed 5 years ago

duhd1993 commented 5 years ago

I have a folder opened and some files in the editor. When going to a definition, it always opens a separate file even if the def is in the same file. And it's like opening a file in other folders -- it shows the full path. It's not like opening a file in the folder. I think it would be better to correct this behavior. Anyway, this will not interfere using the extension, thanks for making this great extension.

duhd1993 commented 5 years ago

image This happens when I try going to the definition of a subroutine in the file.

hansec commented 5 years ago

I think this is likely an issue with how the language server is returning the definition file path. This behavior works as expected for me in all of my projects. What OS are you on? Does this happen with all projects/files, even with a very simple structure of one or two files in a single folder?

The actual extension is just an interface between the language server and builtin functionality in VSCode. So if it turns out to be something other than the language server you'll have to file an issue with VSCode itself.

duhd1993 commented 5 years ago

@hansec I understand this might be issues with the language server or vscode itself. I'm using vscode with gfortran on Windows 10. Not sure of that, but it seems you are using MacOS. c I tried a very simple demo. You can see it was opening file in preview mode even if it's already opened. And it failed finding the definition, this is odd, cuz I don't have this problem with my real project. Sorry if I made any mistake. I just started trying this toolset.

hansec commented 5 years ago

Yes, this is an issue with the language server on Windows. I've been able to isolate the problem and I'll post here once I've pushed a fix. Thanks for the report!

duhd1993 commented 5 years ago

@hansec Thank you! This might be a separate issue. I just found the reason why it failed to find the definition. I added a variable definition at the beginning of the main file. Then it found the subroutine definition with no issue. This barely happens cuz in real project we always have variables. There might be something wrong in the parse part of language server

hansec commented 5 years ago

Ok, just released a patch for the language server (v1.1.1) that I believe should resolve this issue. Let me know if the issue persists after updating the language server. Thanks again for the report!

As for the second issue you saw in the test file, this is due to the lack of variable definition statements or a couple other things. As a result the file was getting misclassified as fixed-form, causing issues. As you mentioned I don't think this is likely to occur in any real files, but if you run into it in a project or when editing let me know.