Support passing --limit to atuin search --delete#3184
Open
keysmashes wants to merge 2 commits intoatuinsh:mainfrom
Open
Support passing --limit to atuin search --delete#3184keysmashes wants to merge 2 commits intoatuinsh:mainfrom
--limit to atuin search --delete#3184keysmashes wants to merge 2 commits intoatuinsh:mainfrom
Conversation
Contributor
Greptile OverviewGreptile SummaryImplements support for using Key changes:
Important Files Changed
Last reviewed commit: f9a0d01 |
As pointed out previously, there are two plausible ways this could be expected to work: 1. The search is executed across (deduplicated) commands, then every usage of the first N commands in the result is deleted. 2. The search is executed across history entries, then the first N history entries in the result are deleted (and other usages of the same command are left intact). With option 1, it's nonsensical to pass `--include-duplicates`: if the results for `atuin search --include-duplicates --limit 3` were "foo", "bar", and "foo", then only two commands would actually be deleted. (If the command "baz" was executed before those three, then without `--include-duplicates` it would have been included in the results – so passing that flag would actually have *reduced* the number of commands being deleted!) With option 2, it's easier to reason about what's happening: every deletion already acts as if `--include-duplicates` was passed, so deletions always operate on individual history entries (not aggregated commands), therefore we don't have to worry about what would happen if `--include-duplicates` was/wasn't passed. To make it obvious that this is how `--limit` works, we require that `--include-duplicates` is *explicitly* passed whenever using `--delete` together with `--limit`.
f9a0d01 to
f441748
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3177.
As pointed out previously (#1436), there are two plausible ways this could be expected to work:
With option 1, it's nonsensical to pass
--include-duplicates: if the results foratuin search --include-duplicates --limit 3were "foo", "bar", and "foo", then only two commands would actually be deleted. (If the command "baz" was executed before those three, then without--include-duplicatesit would have been included in the results – so passing that flag would actually have reduced the number of commands being deleted!)With option 2, it's easier to reason about what's happening: every deletion already acts as if
--include-duplicateswas passed, so deletions always operate on individual history entries (not aggregated commands), therefore we don't have to worry about what would happen if--include-duplicateswas/wasn't passed. To make it obvious that this is how--limitworks, we require that--include-duplicatesis explicitly passed whenever using--deletetogether with--limit.Therefore this PR implements option 2.
Checks