mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +00:00
LibLine: Ignore ENOENT errors when loading old history
A missing history file is just an empty history, so ignore that error
and replace it with an empty array.
This regressed in f93ee3142d
.
This commit is contained in:
parent
4be5000c22
commit
ad899b179f
1 changed files with 7 additions and 1 deletions
|
@ -250,7 +250,13 @@ void Editor::add_to_history(DeprecatedString const& line)
|
||||||
|
|
||||||
ErrorOr<Vector<Editor::HistoryEntry>> Editor::try_load_history(StringView path)
|
ErrorOr<Vector<Editor::HistoryEntry>> Editor::try_load_history(StringView path)
|
||||||
{
|
{
|
||||||
auto history_file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
auto history_file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
|
||||||
|
|
||||||
|
// We ignore "No such file or directory" errors, as that is just equivalent to an empty history.
|
||||||
|
if (history_file_or_error.is_error() && history_file_or_error.error().is_errno() && history_file_or_error.error().code() == ENOENT)
|
||||||
|
return Vector<Editor::HistoryEntry> {};
|
||||||
|
|
||||||
|
auto history_file = history_file_or_error.release_value();
|
||||||
auto data = TRY(history_file->read_until_eof());
|
auto data = TRY(history_file->read_until_eof());
|
||||||
auto hist = StringView { data };
|
auto hist = StringView { data };
|
||||||
Vector<HistoryEntry> history;
|
Vector<HistoryEntry> history;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue