Skip to content

Preserve isearch match data when expanding fragments - #827

Merged
xenodium merged 1 commit into
xenodium:mainfrom
Gleek:fix/restart-preserve-window
Sep 21, 2026
Merged

xenodium merged 1 commit into
xenodium:mainfrom
Gleek:fix/restart-preserve-window

Conversation

@Gleek

@Gleek Gleek commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Running isearch sometimes I get this backtrace:

Debugger entered--Lisp error: (args-out-of-range 0 0)
  agent-shell-ui--isearch-filter-predicate(0 1)
  isearch-lazy-highlight-buffer-update()
  apply(isearch-lazy-highlight-buffer-update nil)
  timer-event-handler([t 27305 6365 618880 nil isearch-lazy-highlight-buffer-update nil nil 0 nil])
  sit-for(0)
  isearch-lazy-highlight-new-loop()
  isearch-post-command-hook()

isearch-filter-predicate must preserve match data. Expanding a fragment calls helpers that can run another search (probably some regex matching code in markdown renderer) which overrides the original match-data. Wrapping the whole thing in save-match-data restores the original match data so isearch is happy.

Single line change, best viewed without whitespace: https://github.com/xenodium/agent-shell/pull/827/changes?w=1

Checklist

  • I agree to communicate (PR description and comments) with the author myself (not AI-generated).
  • I've reviewed all code in PR myself and will vouch for its quality.
  • I've read and followed the Contributing guidelines.
  • I've filed a feature request/discussion for a new feature.
  • I'm making visual changes, so I'm including screenshots so you can view and discuss.
  • I've added tests where applicable.
  • I've updated documentation where necessary.
  • I've run M-x checkdoc and M-x byte-compile-file.

@xenodium

Copy link
Copy Markdown
Owner

Thanks for the improvement. Mind rebasing on to main?

@Gleek
Gleek force-pushed the fix/restart-preserve-window branch from 91e5cd6 to 8225b92 Compare September 20, 2026 14:18
@Gleek

Gleek commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the improvement. Mind rebasing on to main?

done

@xenodium
xenodium merged commit 85600c2 into xenodium:main Sep 21, 2026
2 checks passed
@xenodium

Copy link
Copy Markdown
Owner

Thank you!

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