LibLine: Handle history across multiple concurrent sessions better

- Store history entries as (timestamp)::(entry)\n\n
- Merge the entries together when saving to avoid loss of history
  entries

To ideally make having two concurrently open shells
(or `js` repls or whatever) not overwrite each others' history entries.
This commit is contained in:
AnotherTest
2021-01-11 18:58:42 +03:30
committed by Andreas Kling
parent 711ced80c0
commit 510030971b
5 changed files with 88 additions and 18 deletions

View File

@@ -425,7 +425,7 @@ void Editor::insert_last_words()
{
if (!m_history.is_empty()) {
// FIXME: This isn't quite right: if the last arg was `"foo bar"` or `foo\ bar` (but not `foo\\ bar`), we should insert that whole arg as last token.
if (auto last_words = m_history.last().split_view(' '); !last_words.is_empty())
if (auto last_words = m_history.last().entry.split_view(' '); !last_words.is_empty())
insert(last_words.last());
}
}