Skip to content

Commit

Permalink
Fix incorrect positioning with tabs (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSpicyBurrito authored Sep 29, 2024
1 parent afcfd67 commit a436246
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/decoration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ export const getDecorations = async (

const maxShift = getMaxShift()

const getLineLength = (line: number) =>
editor.document.lineAt(line).range.end.character
const tabWidth = editor.options.tabSize as number

const getLineLength = (line: number) => {
let length = 0
for (const c of editor.document.lineAt(line).text) {
length += c === '\t' ? tabWidth : 1
}

return length
}

const layouts = positions.map((position, i) => {
const paddings: number[] = []
Expand Down

0 comments on commit a436246

Please sign in to comment.