Skip to content

Commit

Permalink
Revert "fix(text): better (correct) way of dealing with \r characte…
Browse files Browse the repository at this point in the history
…rs. Fixes #483"

This reverts commit 520a737.
  • Loading branch information
folke committed May 27, 2023
1 parent 3e1400f commit 06db69a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lua/noice/text/block.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ function Block:_append(content, highlight)
if #self._lines == 0 then
table.insert(self._lines, NuiLine())
end
if type(content) == "string" then
-- handle carriage returns. They overwrite the line from the first character
local cr = content:match("^.*()[\r^M]")
if cr then
table.remove(self._lines)
table.insert(self._lines, NuiLine())
content = content:sub(cr + 1)
end
end
return self._lines[#self._lines]:append(content, highlight)
end

Expand Down Expand Up @@ -179,6 +170,16 @@ function Block:append(contents, highlight)
local nl = text:find("\n")
if nl then
local str = text:sub(1, nl - 1)

-- handle carriage returns. They overwrite the line from the first character
if str:find("\r") then
local parts = vim.split(str, "\r", { plain = true })
str = ""
for _, p in ipairs(parts) do
str = p .. str:sub(p:len() + 1)
end
end

self:_append(str, hl_group)
self:newline()
text = text:sub(nl + 1)
Expand Down

0 comments on commit 06db69a

Please sign in to comment.