Skip to content

Honor noRawHistoryDuplicates while using regular expressions.#518

Open
robwheeler wants to merge 1 commit into
dvorka-oss:masterfrom
robwheeler:master
Open

Honor noRawHistoryDuplicates while using regular expressions.#518
robwheeler wants to merge 1 commit into
dvorka-oss:masterfrom
robwheeler:master

Conversation

@robwheeler

Copy link
Copy Markdown

I noticed that HSTR_CONFIG_DUPLICATES is not honored if HSTR_CONFIG_REGEXP is also set. This pull request fixes that oversight.

@dvorka
dvorka requested review from Copilot and dvorka May 9, 2025 06:53
@dvorka dvorka self-assigned this May 9, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)

Comment thread src/hstr.c
@@ -663,7 +663,7 @@ unsigned print_prompt(void)
return promptLength;
}

Copilot AI May 9, 2025

Copy link

Choose a reason for hiding this comment

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

[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.
*/

Copilot uses AI. Check for mistakes.
@dvorka dvorka assigned robwheeler and unassigned dvorka May 9, 2025
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.

3 participants