diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-12-22 10:46:01 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-12-22 10:46:01 +0800 |
commit | 3ab296ad7e441c75af41e9fe0e94efcce2fb250a (patch) | |
tree | 68742b05e62551fc4a57af3251ac3407467febf4 /script | |
parent | 57cd4d0a87b04f589ca5f6a42c8b2d93aa16dc05 (diff) | |
download | lua-language-server-3ab296ad7e441c75af41e9fe0e94efcce2fb250a.zip |
update utility
Diffstat (limited to 'script')
-rw-r--r-- | script/utility.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/script/utility.lua b/script/utility.lua index 2386998b..a1eec7eb 100644 --- a/script/utility.lua +++ b/script/utility.lua @@ -19,6 +19,7 @@ local utf8Len = utf8.len local mathHuge = math.huge local inf = 1 / 0 local nan = 0 / 0 +local utf8 = utf8 _ENV = nil @@ -477,11 +478,18 @@ function m.viewLiteral(v) end function m.utf8Len(str, start, finish) - local len, pos = utf8Len(str, start, finish, true) - if len then - return len + local len = 0 + for _ = 1, 10000 do + local clen, pos = utf8Len(str, start, finish, true) + if clen then + len = len + clen + break + else + len = len + 1 + utf8Len(str, start, pos - 1, true) + start = pos + 1 + end end - return 1 + m.utf8Len(str, start, pos-1) + m.utf8Len(str, pos+1, finish) + return len end function m.revertTable(t) |