summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-16 20:46:48 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-16 20:46:59 +0800
commitce7c78af623ed45f4f897a4610de8b04aec3d4a4 (patch)
tree9f78575e44ef0112005d11b6475b1137e188b1c7 /script
parent68d88b39691ad7aae0ee1380567c7d40f87ba8d3 (diff)
downloadlua-language-server-ce7c78af623ed45f4f897a4610de8b04aec3d4a4.zip
updata locale
Diffstat (limited to 'script')
-rw-r--r--script/utility.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/script/utility.lua b/script/utility.lua
index 41229f53..f302e706 100644
--- a/script/utility.lua
+++ b/script/utility.lua
@@ -567,25 +567,25 @@ end
---遍历文本的每一行
---@param text string
---@param keepNL boolean # 保留换行符
----@return fun(text:string):string
+---@return fun(text:string):string, integer
function m.eachLine(text, keepNL)
local offset = 1
local lineCount = 0
local lastLine
return function ()
+ lineCount = lineCount + 1
if offset > #text then
if not lastLine then
lastLine = ''
- return ''
+ return '', lineCount
end
return nil
end
- lineCount = lineCount + 1
local nl = text:find('[\r\n]', offset)
if not nl then
lastLine = text:sub(offset)
offset = #text + 1
- return lastLine
+ return lastLine, lineCount
end
local line
if text:sub(nl, nl + 1) == '\r\n' then
@@ -603,7 +603,7 @@ function m.eachLine(text, keepNL)
end
offset = nl + 1
end
- return line
+ return line, lineCount
end
end