Merge pull request #4514 from Granite-Code/Jazzcort/multiline-edit-selection
Fixed multiline selection issue in edit mode
This commit is contained in:
commit
fa0c1d824c
1 changed files with 19 additions and 2 deletions
|
|
@ -551,9 +551,26 @@ const getCommandsMap: (
|
|||
return;
|
||||
}
|
||||
|
||||
const startFromCharZero = editor.selection.start.with(undefined, 0);
|
||||
const document = editor.document;
|
||||
let lastLine, lastChar;
|
||||
// If the user selected onto a trailing line but didn't actually include any characters in it
|
||||
// they don't want to include that line, so trim it off.
|
||||
if (editor.selection.end.character === 0) {
|
||||
// This is to prevent the rare case that the previous line gets selected when user
|
||||
// is selecting nothing and the cursor is at the beginning of the line
|
||||
if (editor.selection.end.line === editor.selection.start.line) {
|
||||
lastLine = editor.selection.start.line;
|
||||
} else {
|
||||
lastLine = editor.selection.end.line - 1;
|
||||
}
|
||||
} else {
|
||||
lastLine = editor.selection.end.line;
|
||||
}
|
||||
lastChar = document.lineAt(lastLine).range.end.character;
|
||||
const endAtCharLast = new vscode.Position(lastLine, lastChar);
|
||||
const range =
|
||||
args?.range ??
|
||||
new vscode.Range(editor.selection.start, editor.selection.end);
|
||||
args?.range ?? new vscode.Range(startFromCharZero, endAtCharLast);
|
||||
|
||||
editDecorationManager.setDecoration(editor, range);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue