diff --git a/src/buffer.cc b/src/buffer.cc index 238c3bc7..17c4a34e 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -53,6 +53,9 @@ static ParsedLines parse_lines(StringView data) pos = eol + 1; } + if (res.lines.empty()) + res.lines.emplace_back(StringData::create({"\n"})); + return res; } @@ -79,9 +82,6 @@ Buffer::Buffer(String name, Flags flags, StringView data, { ParsedLines parsed_lines = parse_lines(data); - if (parsed_lines.lines.empty()) - parsed_lines.lines.emplace_back(StringData::create({"\n"})); - #ifdef KAK_DEBUG for (auto& line : parsed_lines.lines) 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); - if (parsed_lines.lines.empty()) - parsed_lines.lines.emplace_back(StringData::create({"\n"})); - const bool record_undo = not (m_flags & Flags::NoUndo); commit_undo_group();