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
@ -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…
Reference in New Issue
Block a user