From 1997f08d1d7d37b7c2ff6d05324f10dafa449850 Mon Sep 17 00:00:00 2001 From: "shane.xb.qian" Date: Sun, 7 Apr 2024 23:13:06 +0800 Subject: [PATCH] fix: 'GetLineByteFromPos' maybe return val overflow Signed-off-by: shane.xb.qian --- autoload/lsp/util.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autoload/lsp/util.vim b/autoload/lsp/util.vim index eb0a64fb..b9f150dc 100644 --- a/autoload/lsp/util.vim +++ b/autoload/lsp/util.vim @@ -179,6 +179,13 @@ export def GetLineByteFromPos(bnr: number, pos: dict): 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