fix(keymap-upgrader): Fix highlight on last line
Fixed an issue where a text edit at the very end of a file would cause it to highlight from the start of the edit to the start of the file instead of to the end of the file.
This commit is contained in:
parent
c2299e2203
commit
be75da096c
1 changed files with 5 additions and 1 deletions
|
@ -55,7 +55,11 @@ function getLineBreakPositions(text: string) {
|
|||
}
|
||||
|
||||
function positionToLineNumber(position: number, lineBreaks: number[]) {
|
||||
const line = lineBreaks.findIndex((lineBreak) => position <= lineBreak);
|
||||
if (position >= lineBreaks[lineBreaks.length - 1]) {
|
||||
return lineBreaks.length + 1;
|
||||
}
|
||||
|
||||
const line = lineBreaks.findIndex((lineBreak) => position < lineBreak);
|
||||
|
||||
return line < 0 ? 0 : line + 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue