Skip to content

Commit

Permalink
Improve Chat line format
Browse files Browse the repository at this point in the history
  • Loading branch information
luozhiya committed May 21, 2024
1 parent f0158d9 commit 280f279
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/fittencode/views/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ local function set_option_value(window, buffer)
api.nvim_set_option_value('number', false, { win = window })
api.nvim_set_option_value('relativenumber', false, { win = window })
api.nvim_set_option_value('conceallevel', 3, { win = window })
-- api.nvim_set_option_value('scrolloff', 8, { win = window })
end

function M:show()
Expand Down Expand Up @@ -144,14 +145,17 @@ local function format_lines(opts, content)
local fenced_sloved = false
if fenced_code_open then
if fenced_code then
table.insert(lines, 1, '')
if lines[1] ~= '' then
table.insert(lines, 1, '')
end
table.insert(lines, 2, '```')
fenced_code_open = false
fenced_sloved = true
end
end

if not fenced_sloved and firstlinebreak and #content > 0 and #lines > 1 then
if not fenced_code_open and not fenced_sloved and firstlinebreak and
#content > 0 and #lines > 1 then
local last_lines = content[#content]
local last_line = last_lines[#last_lines]
if not string.match(lines[2], '^```') and not string.match(last_line, '^```') then
Expand All @@ -174,7 +178,6 @@ function M:commit(opts)
if not lines then
return
end
Log.debug('Chat Lines: {}', lines)

table.insert(self.content, lines)
_commit(self.window, self.buffer, lines)
Expand Down

0 comments on commit 280f279

Please sign in to comment.