mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
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:
parent
ecb16f421d
commit
886b43e999
Notes:
sideshowbarker
2024-07-19 01:02:28 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/886b43e999c Pull-request: https://github.com/SerenityOS/serenity/pull/4329
1 changed files with 3 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue