LSP icon indicating copy to clipboard operation
LSP copied to clipboard

Unable to open URI

Open titoBouzout opened this issue 1 year ago • 2 comments

Describe the bug

"Unable to open URI" dialog appears when hovering a function and clicking "definition". It happen when triggering the action from a ST window that doesn't have a folder open.

To Reproduce

  1. Open two ST windows
  2. On window 1 open folder "test-project"
  3. on window 1 have file open "test-project/fn.js" with content export function test(){}
  4. on window 2 open file "test-project/some.js" with content import {test} from './fn.js'; test()
  5. hover test() and click "definition"
  6. dialog "Unable to open URI" appears

Environment (please complete the following information):

  • OS: windows 10
  • Sublime Text version: 4175
  • LSP version: na
  • Language servers used: na

Additional context

Im using a fork, but haven't touch this portion of the code. My guess is that this happens on a regular LSP install. It seems to me that the problem happens when LSP cannot find the view for whatever reason. The dialog appears but the functionality seems to work. The problematic code seems to be https://github.com/sublimelsp/LSP/blob/755436391882ca5eec77b3aef534260c8b0c52f7/plugin/locationpicker.py#L31-L35 The function definition is in a different window from where "definition" was invoked, so maybe this check fails for this reason. Maybe the message could be changed to be a status bar message.

titoBouzout avatar Jun 07 '24 07:06 titoBouzout

From the next release, the error message will be printed to the status bar instead of error dialog.

But I am not able to reproduce this error with the given steps. For me the fn.js file opens in the second window too when I click "Definition". I tested with LSP-typescript.

jwortmann avatar Oct 14 '24 15:10 jwortmann

Thanks for looking into the issue. I have tried again and discovered what is the problem. I have this plugin installed https://github.com/titoBouzout/PreventFakeClones

That plugin will prevent opening the same file more than once, and instead will focus the already opened file. This is to prevent having the same file opened more than once on which you may inadvertently make changes to both overwriting each other on each save. This is helpful when working with multiple windows, as you may lose track of what you have open and where.

As fn.js is already opened in window 1, the package prevents opening a copy of fn.js in window 2 when "definition" is click, and focuses the file in window 1. This is all expected to me.

I appreciate moving the message to the status bar.

I am not sure if that code could be improved in some way, maybe instead of opening a copy, it first can check if the file exists in some other window and focus that View instead? I mean, to prevent having copies opened. (which to me could be a problem)

titoBouzout avatar Oct 15 '24 00:10 titoBouzout