Skip to content

Commit

Permalink
fix: 'GetLineByteFromPos' maybe return val overflow
Browse files Browse the repository at this point in the history
Signed-off-by: shane.xb.qian <shane.qian@foxmail.com>
  • Loading branch information
Shane-XB-Qian committed Sep 1, 2024
1 parent 89d5350 commit 1997f08
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions autoload/lsp/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ export def GetLineByteFromPos(bnr: number, pos: dict<number>): number
return byteIdx
endif

# If byteIdx is -1
# If col was an invalid val
var byteLenMax = ltext->len()
if col > byteLenMax
return byteLenMax
endif

return col
enddef

Expand Down

0 comments on commit 1997f08

Please sign in to comment.