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

Expand top-level module and select current function/symbol in breadcrumb #700

Closed
2 tasks done
trkoch opened this issue Mar 18, 2022 · 2 comments
Closed
2 tasks done

Comments

@trkoch
Copy link

trkoch commented Mar 18, 2022

Environment

  • Elixir & Erlang versions (elixir --version): Erlang/OTP 24 [erts-12.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace], Elixir 1.13.3 (compiled with Erlang/OTP 24)
  • VSCode ElixirLS version: 0.9.0
  • Operating System Version: darwin 21.3.0

Troubleshooting

  • Restart your editor (which will restart ElixirLS) sometimes fixes issues
  • Stop your editor, remove the entire .elixir_ls directory, then restart your editor

Issue

The top-level module of the file is not expanded in breadcrumbs. It doesn't expand no matter how wide the window is, or where the cursor is positioned.

image

When on a function within a module and running the command breadcrumbs.focusAndSelect, the top-level module is shown instead of the current function.

image

Data coming from the language server seems to be correct, e.g. the outline view and breadcrumbs (once expanded) look fine and selecting an item jumps to the expected position.

image

Behavior is the same in current VSCode Insiders build.

@lukaszsamson
Copy link
Collaborator

@trkoch The breadcrumbs work but don't expand by default - you can expand them via keyboard. They also do not update when clicking inside source file.
Screenshot 2022-05-31 at 23 19 05
My guess is that vscode expects proper ranges returned in documentSymbols request and we return empty ranges (i.e. start line 5, start char 2, end line 5, end char 2)

         /**
	 * The range enclosing this symbol not including leading/trailing whitespace
	 * but everything else like comments. This information is typically used to
	 * determine if the clients cursor is inside the symbol to reveal in the
	 * symbol in the UI.
	 */
	range: [Range](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range);

	/**
	 * The range that should be selected and revealed when this symbol is being
	 * picked, e.g. the name of a function. Must be contained by the `range`.
	 */
	selectionRange: [Range](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range);

@lukaszsamson lukaszsamson transferred this issue from elixir-lsp/vscode-elixir-ls Jun 11, 2022
@lukaszsamson
Copy link
Collaborator

My guess is that vscode expects proper ranges returned in documentSymbols request and we return empty ranges (i.e. start line 5, start char 2, end line 5, end char 2)

Yes, that was it. I added an implementation returning ranges for most symbols (defmodule, def, attribute, test) where elixir parser returns sufficient metadata. Unfortunately as of elixir 1.13 selection ranges work reliably only for defs (and defs with params). There is no metadata in AST and more difficult hacks would be necessary.

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