better format ts_context text

mine
ray-x 2 years ago
parent fb87a0b1b7
commit df7f4d7229

@ -1,7 +1,9 @@
local log = require('guihua.log').info
local trace = require('guihua.log').trace
local M = {}
local util = require('navigator.util')
local log = util.log
local trace = util.trace
local clone = require('guihua.util').clone
local M = {}
local function filename(url)
if url == nil then
return ''
@ -162,15 +164,7 @@ function M.prepare_for_render(items, opts)
end
if trim then
item.text = string.sub(item.text, 1, l)
local _, j = string.gsub(item.text, [["]], '')
if j % 2 == 1 then
item.text = item.text .. '"'
end
_, j = string.gsub(item.text, [[']], '')
if j % 2 == 1 then
item.text = item.text .. [[']]
end
item.text = item.text .. ''
item.text = util.sub_match(item.text)
-- let check if there are unmatched "/'
end
if #space + #item.text + #ts_report >= win_width then

@ -193,7 +193,8 @@ function M.ref_context(opts)
local text = table.concat(lines, separator)
local text_len = #text
if text_len > indicator_size then
return '' .. text:sub(text_len - indicator_size, text_len)
local str = text:sub(1, text_len)
return util.sub_match(str)
end
return text

@ -556,4 +556,17 @@ function M.dirname(pathname)
return result
end
function M.sub_match(str)
local _, j = string.gsub(str, [["]], '')
if j % 2 == 1 then
str = str .. '"'
end
_, j = string.gsub(str, [[']], '')
if j % 2 == 1 then
str = str .. [[']]
end
str = str .. ''
return str
end
return M

Loading…
Cancel
Save