dmarc3 / vscode-nastran

Nastran Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=mbakke.vscode-nastran&ssr=false
MIT License
7 stars 2 forks source link

error when opening files in v1.0.11 #76

Closed T-solidus-T closed 5 months ago

T-solidus-T commented 5 months ago

Hi,

With the latest version (v1.0.11) I'm getting the following error with all the files I try to open: [Error - 10:11:05 AM] Request textDocument/semanticTokens/range failed. Message: UnboundLocalError: cannot access local variable 'include' where it is not associated with a value Code: -32603 [object Object] Failed to handle request 10 textDocument/semanticTokens/range SemanticTokensRangeParams(text_document=TextDocumentIdentifier(uri='file:///c%3A/Users/xxx/Desktop/tmp/New%20Folder/panel_deformed.bdf'), range=1798:0-1868:56, work_done_token=None, partial_result_token=None) Traceback (most recent call last): File "C:\Users\xxx\Programs_installed\miniconda3\Lib\site-packages\pygls\protocol\json_rpc.py", line 266, in _handle_request self._execute_request(msg_id, handler, params) File "C:\Users\xxx\Programs_installed\miniconda3\Lib\site-packages\pygls\protocol\json_rpc.py", line 188, in _execute_request self._send_response(msg_id, handler(params)) ^^^^^^^^^^^^^^^ File "c:\Users\xxx\Programs\VSCode\data\extensions\mbakke.vscode-nastran-1.0.11\server\server.py", line 120, in semantic_tokens section = get_section(server, include, line_no) ^^^^^^^

Do I need to update/change anything to use this version?

dmarc3 commented 5 months ago

Hey @T-solidus-T , thanks for the bug report. No, you shouldn't need to update anything. It's been working fine for me and the run decks I've opened with it oddly. Are you able to describe how your run deck is structured? The semantic tokening portion of the code handles the alternating 8-char and 16-char field highlighting. The error seems to be saying the include variable is never set which means I'm probably not parsing your file correctly. I suspect if this is happening to you it's probably happening to others too.

I would temporarily downgrade to v1.0.10 if you haven't already while I troubleshoot. I'll have to work this off business hours so it may take a couple days.

T-solidus-T commented 5 months ago

hey @dmarc3 , it does not matter the file I open, I always receive the same error. I've uploaded an example. file.zip

I would temporarily downgrade to v1.0.10 if you haven't already while I troubleshoot.

Yes, for the moment I'm using the v1.0.10 which it works correctly.

I'll have to work this off business hours so it may take a couple days.

And of course, take your time. This is a fantastic extension and if you need anything else, let me know and I'll try to help you.

dmarc3 commented 5 months ago

I was able to test that file you sent and it actually works out of the box for me. Can you share what version of python you're using as well as what version of pygls? Additionally, can you share what version of vscode you're using?

I see from the error message you're using miniconda3 also. I always recommend people use vanilla python where they can. I am unfamiliar with all the conda(s). If you're open to it, I'd recommend you setup vanilla python? I'd suggest going with 3.11 because I am currently not testing 3.12 or 3.13 and I don't know if pygls has been updated for those.

T-solidus-T commented 5 months ago

I'm using python 3.11.5 with pygls 1.2.1. My vscode version is 1.87.2.

Unfortunately, I cannot use vanilla python (work policy issue), we all need to use miniconda (compatibility issues with other projects). But it should not be the problem, don't you think so?

Besides, with v1.0.10 I don't have any problem. Are there many changes between v1.0.10 and v1.0.11? Or is it too complex to track it down?

Edit: just checked with pygls 1.3.0 and I'm still getting the same error

dmarc3 commented 5 months ago

But is should not be the problem, don't you think so?

Agreed. If it was working before, it shouldn't be miniconda3.

Are there many changes between v1.0.10 and v1.0.11?

No, it was a fairly small update though the update to fix the line logging stuff was more involved.

I did forget that I made a very minor update to the semantic token logic to accept bulk data entries spaced by tabs... Before, I was only allowing 8-space, 16-space, and comma separated bulk data entries. Since your error is calling out the semantic token logic, I'll look there first. I will also see about installing miniconda3 so I can test how you're running it. I assume this is where I should get it?

T-solidus-T commented 5 months ago

So maybe it has to do with this "tab parsing". I've also seen that you have implemented a function to open include paths, maybe it's worth taking a look at that code too.

I assume this is where I should get it?

yes, I installed from there.

thank you for your effort of trying to solve this issue :)

dmarc3 commented 5 months ago

I've also seen that you have implemented a function to open include paths

That has been merged into the dev branch but hasn't been released into the wild yet - So that isn't actually in v1.0.11. I'll let you know what I find out after checking out the "tab parsing" and miniconda3.

dmarc3 commented 5 months ago

@T-solidus-T , I was actually able to replicate your error on my install so I do not think it has anything to do with miniconda after all. With v1.0.11, if you press F7 (the keybind to refresh the Include Hierarchy), does the extension begin working as intended? It does for me.

That said, I think I have a solution. Would you be able to test a *.vsix file if I were to send you one? You would just uninstall the extension from the marketplace and then drag and drop the vsix file into the extensions bar in vscode and it'll install it. I'm hoping to confirm this solves your issue before I push an update to the marketplace.

If you join the vscode-nastran discord server here, I can DM you and figure out the best way to get you the file. Let me know if downloading and installing something like that is against your work's policy though... it would be against my work's policy.