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

Make Goto Diagnostic overlays consistent #2115

Merged
merged 4 commits into from
Nov 12, 2022

Conversation

jwortmann
Copy link
Member

At the moment, "Goto Diagnostic..." opens a slightly different overlay compared to invoking "Goto Diagnostic in Project..." and selecting a file. Doing the latter will show the filename in the command palette input and when pressing Backspace it will go back to the list of files, which is not the case for "Goto Diagnostic...".

This PR would make both of the commands to show a consistent overlay by adding the file preselected to the input field for "Goto Diagnostic...".

Feel free to discuss or reject if this implementation feels too dubious/hackish...

plugin/goto_diagnostic.py Outdated Show resolved Hide resolved
plugin/goto_diagnostic.py Outdated Show resolved Hide resolved
plugin/goto_diagnostic.py Outdated Show resolved Hide resolved
plugin/goto_diagnostic.py Outdated Show resolved Hide resolved
@jwortmann
Copy link
Member Author

I think I've addressed all comments.

@jwortmann
Copy link
Member Author

I've noticed that it doesn't look very nice if you open just a single file (without workspace folder): instead of the filename it will show "None" in the command palette input. But this is unrelated to this PR, it also happens on the "main" branch if you run "Goto Diagnostic in Project..." in single file mode. It is just more obvious with this PR.

I think the bug is caused by the following:

This is the function which defines the label:

def description(self, value: DocumentUri, text: str) -> str:
return self._project_path(parse_uri(value))

and it calls _project_path, which returns str(project_path( ... )) or path for file: URIs.

def _project_path(self, parsed_uri: ParsedUri) -> str:
scheme, path = parsed_uri
if scheme == "file":
path = str(project_path(map(Path, self.window.folders()), Path(path))) or path
return path

But the project_path function returns None if there is no window folder:

def project_path(project_folders: Iterable[Path], file_path: Path) -> Optional[Path]:
"""
The project path of `/path/to/project/file` in the project `/path/to/project` is `file`.
"""
folder_path = split_project_path(project_folders, file_path)
if folder_path is None:
return None

So we end up with str(None) or path, which will display as literal "None", i.e. the or path which is probably meant as a fallback, doesn't work at all.

I guess I can add a fix to this PR.

@rchl rchl merged commit cc0d940 into sublimelsp:main Nov 12, 2022
@jwortmann jwortmann deleted the goto-diagnostics-panel branch November 12, 2022 21:15
rchl added a commit that referenced this pull request Jan 16, 2023
* main:
  Nicer presentation for "find references/definition" quick panel (#2109)
  Make Goto Diagnostic overlays consistent (#2115)
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

Successfully merging this pull request may close these issues.

2 participants