Skip to content

Commit

Permalink
Fix off-by-one error in labels' byte length calculation
Browse files Browse the repository at this point in the history
This led to problems with multi-byte chars following a single-character word, e.g. in `_ →` `_` would be a word and due to labels being shifted one char right it would make `→` render incorrectly.
  • Loading branch information
postsolar committed Dec 2, 2023
1 parent f24491d commit 725f568
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4729,7 +4729,7 @@ var getLabels = (v) => {
const selectionDescription = ((orientation === "Forward" ? v.clientSelection.orientation === "Forward" : orientation === "Backward" && v.clientSelection.orientation === "Backward") || !v.autoFlipSelection ? showIntImpl(v.clientSelection.startLine) + "." + showIntImpl(v.clientSelection.startColumn) + "," : showIntImpl(v.clientSelection.endLine) + "." + showIntImpl(v.clientSelection.endColumn) + ",") + showIntImpl(lineNr + lineNrOffset | 0) + "." + showIntImpl(column + 1 | 0);
const jumpPosition = (label) => ({
label,
labelByteLength: byteLength(slice(column + 1 | 0)((column + toCodePointArray(label).length | 0) + 1 | 0)(line))(UTF8),
labelByteLength: byteLength(slice(column)(column + toCodePointArray(label).length | 0)(line))(UTF8),
labelBytePosition: $12,
line: lineNr + lineNrOffset | 0,
selectionDescription,
Expand Down
2 changes: 1 addition & 1 deletion src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ getLabels env@{ labelCharset: Charset labelCharset } =
let
-- Slice of the line where the label is supposed to be
-- Needed to get byte length of the label
labelRangeSlice label = SCU.slice (column + 1) (column + S.length label + 1) line
labelRangeSlice label = SCU.slice column (column + S.length label) line

orientation = jumpOrientation (lineNr + lineNrOffset) column

Expand Down

0 comments on commit 725f568

Please sign in to comment.