#7631·superset

Terminal: show a match count in Cmd+F search and clean up on close

Author: hubertmineCreated Sep 17, 2026Updated Sep 17, 2026

Summary

  • Cmd+F in a terminal tells me only whether a word exists, not how many times or where I am in the list
  • Searching a long agent conversation is the main thing I use it for, and without a count I cannot tell whether Enter is cycling or stuck
  • A few small gaps make it feel unfinished: highlight colours are hardcoded and ignore the theme, every keystroke runs a full search, and the last match stays selected after the bar closes

Today TerminalSearch sets matchCount to found ? 1 : 0, so the UI can only show "No results". The addon already reports the real numbers: onDidChangeResults fires with resultIndex and resultCount (measured: resultCount 16 on a test buffer), and it is unused. Match colours are literals in SEARCH_DECORATIONS (#515c6a / #74879f / #ffd33d) rather than theme tokens, so they clash with imported themes the way #5662 describes for diff comments. handleInputChange calls findNext on every keystroke with no debounce.

Proposal

  • Show "n of m" from onDidChangeResults, and disable the next/previous buttons when there are no matches
  • Derive the highlight colours from the active terminal theme instead of hardcoding them
  • Debounce the search-as-you-type by ~100-150 ms
  • On close, also clear the terminal selection, and clear decorations when the pane unmounts, not only when isOpen flips to false (TerminalPane keeps the xterm instance in the runtime registry across mounts, so an unmount with the bar open leaves highlights behind)

The last two also reduce the fallout from the stale-highlight bug filed separately.