Skip to content

Add History::clear() function - #536

Merged
sholderbach merged 2 commits into
nushell:mainfrom
rgwood:clear-history
Feb 9, 2023
Merged

sholderbach merged 2 commits into
nushell:mainfrom
rgwood:clear-history

Conversation

@rgwood

@rgwood rgwood commented Feb 8, 2023 •

Copy link
Copy Markdown
Contributor

Adds a History::clear() function that deletes all history items. Closes #535.

Will eventually close nushell/nushell#7991

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks

Comment thread src/history/base.rs
Comment on lines +330 to +333
let mut history = create_filled_example_history()?;
assert_ne!(history.count_all()?, 0);
history.clear().unwrap();
assert_eq!(history.count_all()?, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should drop it and try to reopen it, to exclude a potential error case like we were seeing with nushell's sqlite "clear"

@rgwood rgwood Feb 8, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's a good idea but it's a little tricky because create_filled_example_history() doesn't actually create files. It creates an in-memory database for SQLite and never sets the filename for the text history.

It would be nice to have tests that exercise filesystem functionality though 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had such tests but maybe that was before the sqlidation or are only on the individual implementations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sholderbach I've added a test that uses a file-backed history.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg the reedline CI is so fast compared to Nushell 😭

@sholderbach

Copy link
Copy Markdown
Member

Awesome! Thanks.

@sholderbach
sholderbach merged commit d83cc56 into nushell:main Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an API to clear history entirely clearing the history breaks nushell

2 participants