I have a command in an extension, before run the command, I want to change the selection range to get the whole lines...
const sel = textEditor.selection;
const firstLine = textEditor.document.lineAt(sel.start.line);
const lastLine = textEditor.document.lineAt(sel.end.line);
const range = new vscode.Range(firstLine.lineNumber, firstLine.range.start.character, lastLine.lineNumber, lastLine.range.end.character);
I've created a new range, but I don't know how to set the selection of the document to a new range...
new Selection()
has 2 overloads (2 or 4 arguments):Selection(anchor: vscode.Position, active: vscode.Position)
Selection(anchorLine: number, anchorCharacter: number, activeLine: number, activeCharacter: number)
Example, using 4 arguments: