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

[Extension API] Make it possible to remove current selections #680

Closed
Tyriar opened this issue Nov 26, 2015 · 3 comments
Closed

[Extension API] Make it possible to remove current selections #680

Tyriar opened this issue Nov 26, 2015 · 3 comments

Comments

@Tyriar
Copy link
Member

Tyriar commented Nov 26, 2015

I would like to experiment with an extension that removes a selection (provided there are multiple selections active). I don't think that's possible with the current api.

I want to do something like this:

var textEditor = vscode.window.activeTextEditor;
var selections = textEditor.selections;
if (selections.length > 1) {
  textEditor.removeSelection(selections[selections.length - 1]);
}
@jrieken
Copy link
Member

jrieken commented Nov 26, 2015

It is, by just setting a different selection array

Remove the first selection:

var textEditor = vscode.window.activeTextEditor;
var selections = textEditor.selections;

textEditor.selections = selections.slice(1);

@jrieken jrieken closed this as completed Nov 26, 2015
@Tyriar
Copy link
Member Author

Tyriar commented Nov 26, 2015

Thanks, I assumed it was readonly.

@jrieken
Copy link
Member

jrieken commented Nov 26, 2015

In general readonly properties have the @readonly jsdoc tag

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@jrieken @Tyriar and others