Skip to content

Commit

Permalink
test: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ollien authored and xiyaowong committed May 19, 2024
1 parent 19d97b6 commit 977426c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/unit/highlights/highlight_grid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,26 @@ describe("processHighlightCellsEvent", () => {
},
],
},
{
testName: "virtual highlights can exceed line length",
events: [
{
row: 2,
vimCol: 6,
validCells: [{ hlId: 2, text: "!" }],
lineText: "hello",
tabSize: 4,
},
],
expectedRanges: [
{
textType: "virtual" as const,
highlights: [{ hlId: 2, text: "!", virtText: "!" }],
line: 12,
col: 6,
},
],
},
].forEach(
({
testName,
Expand Down
1 change: 1 addition & 0 deletions src/utils/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function calculateEditorColFromVimScreenCol(line: string, screenCol: numb
if (screenCol === 0 || !line) {
return 0;
}

let currentCharIdx = 0;
let currentVimCol = 0;
while (currentVimCol < screenCol) {
Expand Down

0 comments on commit 977426c

Please sign in to comment.