-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(highlight): fix eol highlight not displaying #1988
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,14 @@ export function expandTabs(line: string, tabWidth: number): string { | |
return expanded; | ||
} | ||
|
||
/** | ||
* Note: This function is for use by the highlight module only. | ||
*/ | ||
export function calculateEditorColFromVimScreenCol(line: string, screenCol: number, tabSize: number): number { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. off topic: this could be named |
||
if (screenCol === 0 || !line) { | ||
return 0; | ||
} | ||
|
||
let currentCharIdx = 0; | ||
let currentVimCol = 0; | ||
while (currentVimCol < screenCol) { | ||
|
@@ -33,7 +37,18 @@ export function calculateEditorColFromVimScreenCol(line: string, screenCol: numb | |
} | ||
|
||
if (currentCharIdx >= line.length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ollien Here we cannot use width; what we need is character index There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch. I had a test failure on one of the double-wide unit tests but must have fixed it otherwise |
||
return currentCharIdx; | ||
// The basic logic of highlighting is to store them according | ||
// to the editor column. For EOL highlights, the end-of-line position | ||
// is always used as the decoration position, use CSS | ||
// position offset for display. | ||
|
||
// Typically, the starting vim column in the grid_line event only exceeds the | ||
// line text length when there are EOL highlights, so the offset | ||
// needs to be added directly here. Otherwise, the parts exceeding the | ||
// line text length will use the same editor column, causing EOL highlights | ||
// to be incorrectly covered. | ||
const eolCol = Math.max(screenCol - currentVimCol, 0); | ||
return currentCharIdx + eolCol; | ||
} | ||
} | ||
return currentCharIdx; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for carrying this over. If you would be so kind, would you mind adding a case for where the
Math.max
will trigger return 0, when calculatingeolCol
?