Skip to content

検索パターンが検索語とオプションを写して持つ - #2872

Merged
berryzplus merged 1 commit into
sakura-editor:masterfrom
hpmy-dev:refactor/search_pattern_owns_key
Nov 18, 2026
Merged

berryzplus merged 1 commit into
sakura-editor:masterfrom
hpmy-dev:refactor/search_pattern_owns_key

Conversation

@hpmy-dev

Copy link
Copy Markdown
Contributor

#2865 の対応 2〜5 です。
ここで一旦止めます。

CSearchStringPattern は、SetPattern() に渡された検索語・置換後文字列・検索オプションを指すだけでした。
後で呼び出し側が書き換えると、SetPattern() で作った小文字の検索語や読み飛ばす幅の表と食い違うことがあるので、写して持つ形にします。

変更内容

  • 検索語・置換後文字列を std::wstring・std::optional<std::wstring>、検索オプションを SSearchOption の値で持ちます
  • 小文字の検索語と表を std::wstring・std::vector<int> にします。
    new[]・delete[]、初期値の無い m_nPatternLen、デストラクターが無くなります
  • 文字列検索用に作られていないパターン(設定の前・正規表現・単語単位)では、SearchString() が nullptr を返します
  • SetPattern() の引数と CBregexp の持ち方は変えていません。SearchString() のループは次の PR で整理します

テスト

  • 足したテスト: 書き換えても設定したときの条件で探す(文字列・正規表現)、文字列検索用でないパターンでは nullptr、設定の前の値
  • 文字列検索の今の動きをテストで固定する #2869 のレビューでのご指摘を受けて、1 件の中で SetKey() をし直していたテストを、条件ごとのテストに分けました。
    確かめる値は変えていません
    • 先頭の ASSERT_THAT(SetKey(...), IsTrue()) は残しています。
      SetKey() が失敗すると後ろの確かめに意味が無いので、前提として ASSERT_ にしています。分けたので、止まるのはその条件のテストだけです
  • Win32 Debug: CSearchAgentSearchTest.*・CLineMatchFinderTest.*・CompileRegexpTest.*・CSearchStringPattern.*・GrepParallelTest.* の 126 件が成功

関連 issue, PR

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Test Results

2 074 tests  +22   2 074 ✅ +22   13m 46s ⏱️ + 1m 18s
  177 suites + 1       0 💤 ± 0 
    1 files   ± 0       0 ❌ ± 0 

Results for commit 1354f37. ± Comparison against base commit 7378fdf.

This pull request removes 6 and adds 28 tests. Note that renamed tests count towards both.
CLineMatchFinderTest ‑ SetPatternAgainChangesCase
CLineMatchFinderTest ‑ SetPatternAgainChangesKind
CLineMatchFinderTest ‑ StringIgnoreCaseShortAndLongKey
CLineMatchFinderTest ‑ StringKeyLongerThanLineOrEmpty
CLineMatchFinderTest ‑ StringMatchCaseRejectsDifferentCase
CLineMatchFinderTest ‑ StringSingleCharKey
CLineMatchFinderTest ‑ SearchStringBeforeSetPattern
CLineMatchFinderTest ‑ SearchStringWithRegexPattern
CLineMatchFinderTest ‑ SearchStringWithWordPattern
CLineMatchFinderTest ‑ SetPatternCopiesKeyAndOption
CLineMatchFinderTest ‑ SetPatternIgnoreCaseAfterMatchCase
CLineMatchFinderTest ‑ SetPatternMatchCaseAfterIgnoreCase
CLineMatchFinderTest ‑ SetPatternRegexAfterString
CLineMatchFinderTest ‑ SetPatternStringAfterFailedRegex
CLineMatchFinderTest ‑ SetPatternStringAfterRegex
CLineMatchFinderTest ‑ SetPatternStringAfterWord
…

♻️ This comment has been updated with latest results.

@hpmy-dev
hpmy-dev force-pushed the refactor/search_pattern_owns_key branch from b07ee90 to 1354f37 Compare November 17, 2026 12:34
@sonarqubecloud

Copy link
Copy Markdown

@berryzplus berryzplus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

対応ありがとうございます。

@berryzplus
berryzplus merged commit 38aa781 into sakura-editor:master Nov 18, 2026
17 checks passed
@hpmy-dev
hpmy-dev deleted the refactor/search_pattern_owns_key branch November 19, 2026 00:12
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.

2 participants