Merge pull request #4514 from Granite-Code/Jazzcort/multiline-edit-selection

Fixed multiline selection issue in edit mode
This commit is contained in:
Patrick Erichsen 2025-03-13 15:43:30 -07:00 • committed by GitHub
commit fa0c1d824c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);