Fix: Keep empty lines in discussion tree (#173)

* Docs: Fix typos and remove trailing spaces

* Fix: Split strings by new lines correctly

* Docs: Recommend breakindent option to improve tree nodes indentation

* Fix: Replace whole buffer when creating a new suggestion

Previously, a trailing empty line was left in the buffer.

---------

Co-authored-by: Jakub Bortlík <jakub.bortlik@phonexia.com>
This commit is contained in:
Jakub F. Bortlík
2024-02-10 17:06:56 +01:00
committed by GitHub
parent 132dd60b95
commit d05a23a7d5
7 changed files with 46 additions and 22 deletions

View File

@@ -148,6 +148,16 @@ M.trim = function(s)
return res
end
---Splits a string by new lines and returns an iterator
---@param s string The string to split
---@return table: An iterator object
M.split_by_new_lines = function(s)
if s:sub(-1) ~= "\n" then
s = s .. "\n"
end -- Append a new line to the string, if there's none, otherwise the last line would be lost.
return s:gmatch("(.-)\n") -- Match 0 or more (as few as possible) characters followed by a new line.
end
-- Reverses the order of elements in a list
---@param list table The list to reverse
---@return table