diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-31 12:46:05 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-31 12:46:05 +0800 |
commit | 92e4da8c7cec41b0595c59ac91345a812d902975 (patch) | |
tree | 84a64dda769b723c694107afd4a3b95b57936978 /server/test | |
parent | dac81ea089eb6970c81859ff2a0bb233f3eb159f (diff) | |
download | lua-language-server-92e4da8c7cec41b0595c59ac91345a812d902975.zip |
更新lni
Diffstat (limited to 'server/test')
-rw-r--r-- | server/test/main.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/server/test/main.lua b/server/test/main.lua index 10d5e155..9fa46e26 100644 --- a/server/test/main.lua +++ b/server/test/main.lua @@ -16,6 +16,59 @@ ac = {} require 'utility' require 'global_protect' + local function convertLni() + local function scan(path, callback) + if fs.is_directory(path) then + for child in path:list_directory() do + scan(child, callback) + end + else + callback(path) + end + end + + local function callback(path) + local ext = path:extension() + if ext:string() ~= '.lni' then + return + end + local buf = io.load(path) + local lines = {} + local cur = 1 + while true do + local pos = buf:find('[\r\n]', cur) + if pos then + lines[#lines+1] = buf:sub(cur, pos - 1) + if buf:sub(pos, pos + 1) == '\r\n' then + cur = pos + 2 + else + cur = pos + 1 + end + else + lines[#lines+1] = buf:sub(cur) + break + end + end + local last = '' + for i, line in ipairs(lines) do + if line:sub(1, 1) == '[' and line:sub(-1, -1) == ']' then + if line:sub(1, 2) == '[[' and line:sub(-2, -1) == ']]' then + if line == last then + lines[i] = '``````````' + end + end + last = line + end + end + local newBuf = table.concat(lines, '\r\n') + io.save(path, newBuf) + end + + scan(ROOT / 'libs', callback) + scan(ROOT / 'locale', callback) +end +--convertLni() + local function main() local function test(name) local clock = os.clock() |