Honor noRawHistoryDuplicates while using regular expressions.#518
Open
robwheeler wants to merge 1 commit into
Open
Honor noRawHistoryDuplicates while using regular expressions.#518robwheeler wants to merge 1 commit into
robwheeler wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the oversight where HSTR_CONFIG_DUPLICATES was not being honored when HSTR_CONFIG_REGEXP is set by updating the selection functions to accommodate optional regular expression match information.
- Renamed and refactored the selection addition functions to conditionally include regex match data.
- Replaced direct calls to add_to_selection with wrappers that support both regex and non-regex modes.
Comments suppressed due to low confidence (1)
src/hstr.c:684
- [nitpick] The relationship between maybe_add_to_selection and maybe_add_to_selection_regexp could be made clearer; consider renaming or documenting these functions to more explicitly convey when regex match details are expected.
void maybe_add_to_selection(char* line, unsigned int* index)
| @@ -663,7 +663,7 @@ unsigned print_prompt(void) | |||
| return promptLength; | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
[nitpick] Consider adding a comment to explain the behavior of maybe_add_to_selection_regexp, particularly how it utilizes the regexpMatch parameter when provided versus when it is NULL.
Suggested change
| /** | |
| * Adds a line to the selection array if it is not already present (when duplicates are disallowed). | |
| * If `regexpMatch` is provided, the regular expression match data is stored in `hstr->selectionRegexpMatch`. | |
| * If `regexpMatch` is NULL, no match data is stored. | |
| * | |
| * @param line The line to be added to the selection. | |
| * @param index Pointer to the current index in the selection array. | |
| * @param regexpMatch Pointer to a `regmatch_t` structure containing match data, or NULL. | |
| */ |
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.
I noticed that HSTR_CONFIG_DUPLICATES is not honored if HSTR_CONFIG_REGEXP is also set. This pull request fixes that oversight.