close
Skip to content

Commit a226280

Browse files
chiragjaggaabdnh
andauthored
fix: regex error fix (#4837)
<!-- Title (for the Pull Request title field at the top): Use a short prefix so the change type is obvious. You do not need to repeat it in the body below. Examples: - fix: — bugfix - feat: — feature - refactor: — internal change without user-facing feature - docs: — documentation only - chore: — tooling, CI, deps, build housekeeping - test: — tests only --> ## Linked issue (required) Fixes #4835 ## Summary / motivation (required) <!-- What this PR does and why. For larger changes, add enough context for reviewers. --> Fixes the issue #4835 with a minor change in InvalidRegex error. ## Steps to reproduce (required, use N/A if not applicable) <!-- Steps to reproduce: how to trigger the bug in the broken state (the "before"). - Mainly for bugfixes; - For bugs: numbered steps before the fix. For non-bugs: write N/A. - use N/A for features, refactors, docs, chore, etc. --> 1. Open the browser and do a find & replace. 2. Put b[ in “Find”. 3. Enable the regex option. 4. Confirm. ## How to test (required) <!--- How to test: how you verified the change (checks, unit tests, manual steps, edge cases — the "after" or general validation). ---> Reproduce the fix and verify the regex error is not within the `<pre>` tag. ### Checklist (minimum) - [x] I ran `./ninja check` or an equivalent relevant check locally. - [x] I added or updated tests when the change is non-trivial or behavior changed. ### Details Regex error was return with `<pre>` tags which are removed now so that the text in the error box is displayed correctly. ## Before / after behavior (optional) <img width="372" height="211" alt="image" src="https://github.com/user-attachments/assets/91f53745-301b-4679-b1a5-53fafd628de7" /> <!-- For bugfixes: behavior before vs after. For other types: N/A or a short note. --> ## Risk / compatibility / migration (optional) <!-- Breaking changes, rollout notes, or N/A for small / low-risk PRs --> ## UI evidence (required for visual changes; otherwise N/A) <img width="360" height="226" alt="image" src="https://github.com/user-attachments/assets/3b7b3f23-9f35-423e-9b10-62834e0a0dd6" /> <!-- Screenshot or short video --> ## Scope - [x] This PR is focused on one change (no unrelated edits). --------- Co-authored-by: Abdo <abdo@abdnh.net>
1 parent cc1605a commit a226280

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

‎CONTRIBUTORS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ barisayyildiz <99ayyldzbaris99@gmail.com>
276276
Christos Longros <chris.longros@gmail.com>
277277
Maskady <florent.tout@gmail.com>
278278
Jeremy Fleischman <jeremyfleischman@gmail.com>
279+
Chirag Jagga <chiragjagga26@gmail.com>
279280

280281
********************
281282

‎qt/aqt/browser/find_and_replace.py‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

66
from collections.abc import Sequence
77

8+
from markdown import markdown
9+
810
import aqt
911
import aqt.forms
1012
import aqt.operations
13+
from anki.collection import OpChangesWithCount
1114
from anki.notes import NoteId
1215
from aqt import AnkiQt
1316
from aqt.operations import QueryOp
@@ -27,6 +30,7 @@
2730
save_combo_index_for_session,
2831
save_is_checked,
2932
saveGeom,
33+
showWarning,
3034
tooltip,
3135
tr,
3236
)
@@ -164,16 +168,19 @@ def accept(self) -> None:
164168
match_case=match_case,
165169
)
166170

167-
if not self.note_ids:
168-
op.success(
169-
lambda out: tooltip(
170-
tr.browsing_notes_updated(count=out.count),
171-
parent=self.parentWidget(),
171+
def on_success(changes: OpChangesWithCount) -> None:
172+
if self.note_ids:
173+
message = tr.findreplace_notes_updated(
174+
changed=changes.count, total=len(self.note_ids)
172175
)
173-
)
174-
op.run_in_background()
176+
else:
177+
message = tr.browsing_notes_updated(count=changes.count)
178+
tooltip(message, parent=self.parentWidget())
179+
super(FindAndReplaceDialog, self).accept()
175180

176-
super().accept()
181+
op.success(on_success)
182+
op.failure(lambda err: showWarning(markdown(str(err))))
183+
op.run_in_background()
177184

178185
def show_help(self) -> None:
179186
openHelp(HelpPage.BROWSING_FIND_AND_REPLACE)

0 commit comments

Comments
 (0)