Skip to content

Fix SelectionMatchFindAction to respect seedSearchStringFromSelection setting#300086

Open
teoincontatto wants to merge 2 commits into
microsoft:mainfrom
teoincontatto:fix/selection-match-find-respects-seed-setting
Open

Fix SelectionMatchFindAction to respect seedSearchStringFromSelection setting#300086
teoincontatto wants to merge 2 commits into
microsoft:mainfrom
teoincontatto:fix/selection-match-find-respects-seed-setting

Conversation

@teoincontatto
Copy link
Copy Markdown

Summary

  • Makes editor.action.nextSelectionMatchFindAction and editor.action.previousSelectionMatchFindAction respect the editor.find.seedSearchStringFromSelection setting
  • Previously these actions hardcoded getSelectionSearchString(editor, 'single', false), always enabling the word-at-cursor fallback regardless of user configuration
  • Now reads the setting and passes it through consistently, matching the behavior of StartFindAction and other find actions

Fixes #300085

Change

One-line change in SelectionMatchFindAction.run() (src/vs/editor/contrib/find/browser/findController.ts):

Before:

const selectionSearchString = getSelectionSearchString(editor, 'single', false);

After:

const seedSearchStringFromSelection = editor.getOption(EditorOption.find).seedSearchStringFromSelection;
const selectionSearchString = seedSearchStringFromSelection !== 'never'
    ? getSelectionSearchString(editor, 'single', seedSearchStringFromSelection === 'selection')
    : null;

Behavior by setting value

Setting Before (broken) After (fixed)
"always" (default) Seeds from selection or word at cursor Same (no change)
"selection" Seeds from selection or word at cursor Seeds from selection only
"never" Seeds from selection or word at cursor Never seeds

Test plan

  • With "editor.find.seedSearchStringFromSelection": "always" (default): select text, Cmd+F3, paste replacement, Cmd+F3 again → picks up word at cursor (unchanged behavior)
  • With "editor.find.seedSearchStringFromSelection": "selection": select text, Cmd+F3, paste replacement, Cmd+F3 again → continues searching previous term (fixed)
  • With "editor.find.seedSearchStringFromSelection": "never": Cmd+F3 never seeds from editor (fixed)
  • Same scenarios with editor.action.previousSelectionMatchFindAction

@benibenj benibenj assigned osortega and unassigned benibenj Mar 9, 2026
@teoincontatto teoincontatto force-pushed the fix/selection-match-find-respects-seed-setting branch from c92ab58 to 1e3279d Compare March 18, 2026 11:32
The `editor.action.nextSelectionMatchFindAction` and
`editor.action.previousSelectionMatchFindAction` commands previously
hardcoded `getSelectionSearchString(editor, 'single', false)`, ignoring
the `editor.find.seedSearchStringFromSelection` setting entirely. This
caused the action to always pick up the word at the cursor position when
there was no active selection, even when the user had configured the
setting to `"selection"` to prevent this behavior.

Now the `SelectionMatchFindAction` reads the
`editor.find.seedSearchStringFromSelection` option and passes it through
consistently, matching the behavior of `StartFindAction` and other find
actions:
- `"always"` (default): seeds from selection or word at cursor (unchanged)
- `"selection"`: seeds only from an actual selection, not word at cursor
- `"never"`: never seeds the search string from the editor

Fixes the workflow where a user selects text, uses Find Next Selection
Match, pastes a replacement, then expects the next invocation to
continue searching for the original term rather than picking up the word
at the cursor.
@teoincontatto teoincontatto force-pushed the fix/selection-match-find-respects-seed-setting branch from 1e3279d to 7c3b0f5 Compare March 18, 2026 14:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes SelectionMatchFindAction (next/previous selection match find actions) to honor the editor.find.seedSearchStringFromSelection setting, aligning its behavior with StartFindAction and other find actions. Previously it hardcoded the word-at-cursor fallback regardless of user configuration.

Changes:

  • Read editor.find.seedSearchStringFromSelection option in SelectionMatchFindAction.run().
  • Skip seeding when set to 'never', and only enable word-at-cursor fallback when set to 'always'.
Show a summary per file
File Description
src/vs/editor/contrib/find/browser/findController.ts Replace hardcoded getSelectionSearchString(editor, 'single', false) call with logic that respects the seedSearchStringFromSelection setting.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

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.

SelectionMatchFindAction ignores editor.find.seedSearchStringFromSelection setting

4 participants