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

DocumentSymbol.selectionRange doesn't seem to work #54857

Closed
Gama11 opened this issue Jul 23, 2018 · 8 comments
Closed

DocumentSymbol.selectionRange doesn't seem to work #54857

Gama11 opened this issue Jul 23, 2018 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug outline Source outline view issues quick-pick Quick-pick widget issues verified Verification succeeded
Milestone

Comments

@Gama11
Copy link
Contributor

Gama11 commented Jul 23, 2018

  • VSCode Version: 1.25.1
  • OS Version: Windows 10

The docs for DocumentSymbol.selectionRange state:

The range that should be selected and reveal when this symbol is being picked, e.g the name of a function.

To me, this implies that picking a symbol from Ctrl+Shift+O selects this range (not sure what else it would be for, selecting something in the Outline view doesn't set a cursor selection / only navigates to the line).

Instead, the cursor is positioned at the start of range (in this example, the selectionRange covers name).

import * as vscode from "vscode";

export function activate(context: vscode.ExtensionContext) {
	vscode.languages.registerDocumentSymbolProvider('plaintext', {
		provideDocumentSymbols: (): vscode.DocumentSymbol[] => {
			return [new vscode.DocumentSymbol("name", "", vscode.SymbolKind.Variable,
                               new vscode.Range(0, 0, 1, 0), new vscode.Range(0, 4, 0, 8))];
		}
	});
}

I would expect the cursor to be positioned before name, and perhaps also select it. Originally brought this up in microsoft/vscode-languageserver-node#373 (comment).

@jrieken
Copy link
Member

jrieken commented Jul 24, 2018

Yeah, we didn't adopt that for quick outline (yet) but only for the outline tree and the breadcrumbs

@jrieken jrieken added this to the July 2018 milestone Jul 24, 2018
@jrieken jrieken added outline Source outline view issues bug Issue identified by VS Code Team member as probable bug quick-pick Quick-pick widget issues and removed editor labels Jul 24, 2018
@jrieken
Copy link
Member

jrieken commented Jul 24, 2018

Pushed a fix to use the selectionRange property. @Gama11 Tho be aware that the highlighting is always full lines, not columns, so that in your sample no change can be observed.

@jrieken
Copy link
Member

jrieken commented Jul 24, 2018

Nevermind - pushed another change so that the range will be use for the (yellow) highlight and the selectionRange will be used for the revealing

@Gama11
Copy link
Contributor Author

Gama11 commented Jul 24, 2018

Thanks! I'll check it out in the next Insider's build that includes the changes.

@jrieken jrieken closed this as completed Jul 24, 2018
@Gama11
Copy link
Contributor Author

Gama11 commented Jul 25, 2018

Thanks, now it's working as I'd expect. 👍

One question: should doc comments before fields / types be included in range? Intuitively I'd say yes, since it makes sense that selecting e.g. a field's doc comment would highlight the corresponding symbol in the Outline view. However, TypeScript doesn't seem to do that (I often treat TS support as a sort of "reference implementation" for various language features and check how things are done there).

@jrieken
Copy link
Member

jrieken commented Jul 25, 2018

One question: should doc comments before fields / types be included in range? Intuitively I'd say yes, since it makes sense that selecting e.g. a field's doc comment would highlight the corresponding symbol in the Outline view.

Yeah, I'd also say yes.

Gama11 added a commit to vshaxe/haxe-language-server that referenced this issue Jul 25, 2018
E.g. enum constructors, simple typedef fields...
The difference is only visible with VSCode 1.26, see microsoft/vscode#54857.
Gama11 added a commit to vshaxe/haxe-language-server that referenced this issue Jul 25, 2018
Disabled for now until VSCode 1.26 is out because of microsoft/vscode#54857 (otherwise selecting something would select the start of the doc comment instead of the symbol).
@JacksonKearl
Copy link
Contributor

@jrieken What is the desired behavior here? Not seeing any difference between range and selection range. In particular, not seeing the "yellow highlight".

@JacksonKearl JacksonKearl added the verification-steps-needed Steps to verify are needed for verification label Aug 3, 2018
@jrieken jrieken removed the verification-steps-needed Steps to verify are needed for verification label Aug 6, 2018
@jrieken
Copy link
Member

jrieken commented Aug 6, 2018

To verify

  • have the extension snippet above
  • open quick outline
  • select the element and make sure the cursor is at line 1 column 5, not at 1,1

@joaomoreno joaomoreno added the verified Verification succeeded label Aug 6, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug outline Source outline view issues quick-pick Quick-pick widget issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants