LibLine: Don't make Editor::load_history() cut off a character per line

For some reason we were not considering the last *two* characters from
the line's ByteBuffer, with the comment next to it talking about \n and
\0. However the buffer doesn't contain a null-byte, so we were
effectively removing the newline and the last character from each
history line!
This commit is contained in:
Linus Groh 2020-12-05 17:57:45 +00:00 committed by Andreas Kling
parent ecb16f421d
commit 886b43e999
Notes: sideshowbarker 2024-07-19 01:02:28 +09:00

View file

@ -226,9 +226,9 @@ bool Editor::load_history(const String& path)
if (!history_file->open(Core::IODevice::ReadOnly))
return false;
while (history_file->can_read_line()) {
auto b = history_file->read_line(1024);
// skip the newline and terminating bytes
add_to_history(String(reinterpret_cast<const char*>(b.data()), b.size() - 2));
auto buffer = history_file->read_line(1024);
// -1 to skip the newline character
add_to_history(String(reinterpret_cast<const char*>(buffer.data()), buffer.size() - 1));
}
return true;
}