You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
textDocument/didOpen not called when language server doesn't support codelens, highlight, etc #1224
(Make sure $PyInterpreterDirectory$/python is the same python as the one with pygls installed. If not using PyCharm, you may have to provide the absolute path to the python interpreter binary instead of $PyInterpreterDirectory$/python, and the absolute path to s.py instead of $PROJECT_DIR$/s.py.)
Close all open code editor windows without exiting PyCharm, then open test1.py in PyCharm, then exit PyCharm with test1.py still open.
Re-open PyCharm, which should automatically launch the language server and open test1.py at the same time.
Open test2.py
Close test1.py
Close test2.py
Results
Expected behaviour is showing in LSP4IJ v0.12.0 Language Server. Logs below:
Ignoring notification for unknown method "workspace/didChangeConfiguration"
OPENED /absolute/path/to/project/test1.py
OPENED /absolute/path/to/project/test2.py
CLOSED /absolute/path/to/project/test1.py
CLOSED /absolute/path/to/project/test2.py
Unexpected behaviour is showing in LSP4IJ v0.14.2 Language Server. Logs below:
Ignoring notification for unknown method "workspace/didChangeConfiguration"
OPENED /absolute/path/to/project/test1.py
<no event for test2.py>
CLOSED /absolute/path/to/project/test1.py
<no event for test2.py>
The traces are reproduced from the sequence of steps given in the top post. In particular,
The first didOpen (on test1.py) comes from step 5 and 6, triggered by the automatic re-opening of test1.py upon launching PyCharm.
The second didOpen (on test2.py) comes from step 7, triggered by the user manually opening test2.py. (This only triggers on LSP4IJ v0.12.0; it doesn't trigger on LSP4IJ v0.14.2, which is the cause of this bug report).
@bzoracler the main difference between 0.12 and 0.13 is that didOpen should call only when file tab is visible. Technically when IJ consumes highlight, codevision, etc when editor is displayed.
Before 0.13.0 didOpen occurs when IJ fileOpen is sent. This sent is done for all opened files even if it is not visible.
This behavior is the same than vscode and improve performance when IJ starts. If you have a lot of files opened which are associated to several servers, only the server associated to visible tab file will be started.
In other words you need to click on the editor tab to have a didOpen. Is it working for you?
No, for me the didOpen in v0.13 and newer only triggers for file tabs that are automatically opened when launching PyCharm (these automatically-opened windows are the ones not closed when exiting the previous PyCharm session).
Newer opened file tabs do not trigger didOpen at all (see step 7 in the top post; didOpen doesn't appear in the trace for test2.py for LSP4IJ 0.14.2).
The real language server I'm using does not use highlight, code lens, codevision, or inlay hint. It currently only uses textDocument/publishDiagnostics, which I need upon opening a code editor window.
This is LSP4IJ 0.14.2, the editor tab for test2.py is open (I manually opened it) but does not have trace for didOpen. test1.py has a trace because it was automatically opened when I launched PyCharm (I didn't close test1.py when I exited PyCharm last session).
In LSP4IJ 0.12.0, both test1.py and test2.py would show didOpen traces.
changed the title [-]`textDocument/didOpen` stopped working properly with pygls after v0.12.0[/-][+]`textDocument/didOpen` not called when language server doesn't supports codelens, highlight, etc[/+]on Aug 20, 2025
changed the title [-]`textDocument/didOpen` not called when language server doesn't supports codelens, highlight, etc[/-][+]`textDocument/didOpen` not called when language server doesn't support codelens, highlight, etc[/+]on Aug 20, 2025
Activity
angelozerr commentedon Aug 20, 2025
Could yiu share your full lsp traces please
bzoracler commentedon Aug 20, 2025
lsp4ij-0.12.0-trace.txt
lsp4ij-0.14.2-trace.txt
bzoracler commentedon Aug 20, 2025
Oops, I omitted the end of the trace from LSP4IJ 0.12.0 sample, it should have this at the end:
angelozerr commentedon Aug 20, 2025
Thanks for the lsp traces.
I dont understand what your ls provides as lsp features. Therevare no highlight, codelens, inlayhint support which should force the didOpen
bzoracler commentedon Aug 20, 2025
The traces are reproduced from the sequence of steps given in the top post. In particular,
didOpen(ontest1.py) comes from step 5 and 6, triggered by the automatic re-opening oftest1.pyupon launching PyCharm.didOpen(ontest2.py) comes from step 7, triggered by the user manually openingtest2.py. (This only triggers on LSP4IJ v0.12.0; it doesn't trigger on LSP4IJ v0.14.2, which is the cause of this bug report).angelozerr commentedon Aug 20, 2025
@bzoracler the main difference between 0.12 and 0.13 is that didOpen should call only when file tab is visible. Technically when IJ consumes highlight, codevision, etc when editor is displayed.
Before 0.13.0 didOpen occurs when IJ fileOpen is sent. This sent is done for all opened files even if it is not visible.
This behavior is the same than vscode and improve performance when IJ starts. If you have a lot of files opened which are associated to several servers, only the server associated to visible tab file will be started.
In other words you need to click on the editor tab to have a didOpen. Is it working for you?
bzoracler commentedon Aug 20, 2025
No, for me the
didOpenin v0.13 and newer only triggers for file tabs that are automatically opened when launching PyCharm (these automatically-opened windows are the ones not closed when exiting the previous PyCharm session).Newer opened file tabs do not trigger
didOpenat all (see step 7 in the top post;didOpendoesn't appear in the trace fortest2.pyfor LSP4IJ 0.14.2).The real language server I'm using does not use highlight, code lens, codevision, or inlay hint. It currently only uses
textDocument/publishDiagnostics, which I need upon opening a code editor window.bzoracler commentedon Aug 20, 2025
This is LSP4IJ 0.14.2, the editor tab for
test2.pyis open (I manually opened it) but does not have trace fordidOpen.test1.pyhas a trace because it was automatically opened when I launched PyCharm (I didn't closetest1.pywhen I exited PyCharm last session).In LSP4IJ 0.12.0, both
test1.pyandtest2.pywould showdidOpentraces.angelozerr commentedon Aug 20, 2025
Ok I think the cause of your problem is that your language server has no highlight, codelens, inlayhint which forces the didOpen.
Let me investigate how to fix that.
[-]`textDocument/didOpen` stopped working properly with pygls after v0.12.0[/-][+]`textDocument/didOpen` not called when language server doesn't supports codelens, highlight, etc[/+]fix: `textDocument/didOpen` not called when language server doesn't
[-]`textDocument/didOpen` not called when language server doesn't supports codelens, highlight, etc[/-][+]`textDocument/didOpen` not called when language server doesn't support codelens, highlight, etc[/+]fix: `textDocument/didOpen` not called when language server doesn't
fix: `textDocument/didOpen` not called when language server doesn't
fix: `textDocument/didOpen` not called when language server doesn't
fix: `textDocument/didOpen` not called when language server doesn't
angelozerr commentedon Aug 20, 2025
@bzoracler when https://github.com/redhat-developer/lsp4ij/actions/runs/17108157690 will be finished, please install https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds and tell me if it fixes your issue.
bzoracler commentedon Aug 20, 2025
Thank you, I will test the build and get back to looking at #1223 if it works.
angelozerr commentedon Aug 20, 2025
Hope it will work and if it is working, please wait that rebase was done in #1223 (see #1223 (comment))
bzoracler commentedon Aug 20, 2025
@angelozerr Thank you for the fast fix, this worked great!
angelozerr commentedon Aug 20, 2025
That's great! If you like LSP4IJ, don't hesitate to add a review at JetBrains Marketplace to help us to promote LSP4IJ.
bzoracler commentedon Aug 20, 2025
Don't worry, I've left a 5-star review back in February :)
Thanks again for the great product!
angelozerr commentedon Aug 20, 2025
Ooops sorry I have forgotten that.