Skip to content

LSP client stops working on file after renaming it #7806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lcbarcellos opened this issue Sep 27, 2024 · 1 comment · May be fixed by #7829
Open

LSP client stops working on file after renaming it #7806

lcbarcellos opened this issue Sep 27, 2024 · 1 comment · May be fixed by #7829
Assignees
Labels
kind:bug Bug report or fix LSP [ci] enable Language Server Protocol tests

Comments

@lcbarcellos
Copy link

Apache NetBeans version

Apache NetBeans 23

What happened

When I rename a typescript file using project window, completion stops working on that file.

An unexpected exception shows up in notifications window like below (I've edited the file name):

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Request textDocument/completion failed with message: The document should be opened for completion, file: /path/to/typescript/file.ts
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused: java.util.concurrent.ExecutionException
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
[catch] at org.netbeans.modules.lsp.client.bindings.CompletionProviderImpl$2.query(CompletionProviderImpl.java:161)
	at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:198)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)

If I rename the file back to its original name, completion starts working again. Closing file and reopening it also works around the issue.

Language / Project Type / NetBeans Component

No response

How to reproduce

  • Open a typescript file
  • check whether completion is working
  • Go to Projects Window (ctrl + 1)
  • Rename that file
  • Go back to file edit window. Completion should not work anymore
  • An exception should be present in Notifications window

Did this work correctly in an earlier version?

No / Don't know

Operating System

Ubuntu 22.04

JDK

OpenJDK Runtime Environment 17.0.12+7-Ubuntu-1ubuntu222.04

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

Every time.

Are you willing to submit a pull request?

No

@lcbarcellos lcbarcellos added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Sep 27, 2024
@mbien mbien added the LSP [ci] enable Language Server Protocol tests label Sep 29, 2024
@matthiasblaesing matthiasblaesing self-assigned this Oct 3, 2024
@matthiasblaesing matthiasblaesing removed the needs:triage Requires attention from one of the committers label Oct 3, 2024
matthiasblaesing added a commit to matthiasblaesing/netbeans that referenced this issue Oct 3, 2024
The LSP protocol requires that when a file is renamed the client
signals this to the server by sending a didClose for the old location
and after that a didOpen with the new location.

The change assumes, that the IDE always goes through the DataObject to
issue the rename/move. Changes through the raw FileObject are not
tracked.

Closes: apache#7806
matthiasblaesing added a commit to matthiasblaesing/netbeans that referenced this issue Oct 3, 2024
The LSP protocol requires that when a file is renamed the client
signals this to the server by sending a didClose for the old location
and after that a didOpen with the new location.

The change assumes, that the IDE always goes through the DataObject to
issue the rename/move. Changes through the raw FileObject are not
tracked.

Closes: apache#7806
@matthiasblaesing
Copy link
Contributor

@lcbarcellos thanks for bringing this up. I noticed the problem in the past, but always postponed looking further. Please have a look at #7829.
There is a nightly build with the change Checks page direct link
Please see if that fixes the issue for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix LSP [ci] enable Language Server Protocol tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants