From 947e071066f5f3cc4f586aaeb6205b4663854187 Mon Sep 17 00:00:00 2001 From: Delapouite Date: Sat, 27 Apr 2019 19:29:16 +0200 Subject: [PATCH] Let parse_lines ensure that there's at least 1 line with \n --- src/buffer.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index 238c3bc76..17c4a34e1 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();