Skip to content
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

Unable to open URI #2490

Open
titoBouzout opened this issue Jun 7, 2024 · 2 comments
Open

Unable to open URI #2490

titoBouzout opened this issue Jun 7, 2024 · 2 comments

Comments

@titoBouzout
Copy link
Contributor

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

def check_success_async(view: sublime.View | None) -> None:
if not view:
sublime.error_message("Unable to open URI")
session.open_location_async(location, flags, group).then(check_success_async)

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.

@jwortmann
Copy link
Member

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.

@titoBouzout
Copy link
Contributor Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants