Merge remote-tracking branch 'Delapouite/parse_lines'

This commit is contained in:
Maxime Coste 2019-05-01 03:48:48 +10:00
commit f96547719d

View File

@ -53,6 +53,9 @@ static ParsedLines parse_lines(StringView data)
pos = eol + 1; pos = eol + 1;
} }
if (res.lines.empty())
res.lines.emplace_back(StringData::create({"\n"}));
return res; return res;
} }
@ -79,9 +82,6 @@ Buffer::Buffer(String name, Flags flags, StringView data,
{ {
ParsedLines parsed_lines = parse_lines(data); ParsedLines parsed_lines = parse_lines(data);
if (parsed_lines.lines.empty())
parsed_lines.lines.emplace_back(StringData::create({"\n"}));
#ifdef KAK_DEBUG #ifdef KAK_DEBUG
for (auto& line : parsed_lines.lines) for (auto& line : parsed_lines.lines)
kak_assert(not (line->length == 0) and kak_assert(not (line->length == 0) and
@ -245,9 +245,6 @@ void Buffer::reload(StringView data, timespec fs_timestamp)
{ {
ParsedLines parsed_lines = parse_lines(data); ParsedLines parsed_lines = parse_lines(data);
if (parsed_lines.lines.empty())
parsed_lines.lines.emplace_back(StringData::create({"\n"}));
const bool record_undo = not (m_flags & Flags::NoUndo); const bool record_undo = not (m_flags & Flags::NoUndo);
commit_undo_group(); commit_undo_group();