Skip to content

SelectionMatchFindAction ignores editor.find.seedSearchStringFromSelection setting #300085

@teoincontatto

Description

@teoincontatto

Bug Description

The editor.action.nextSelectionMatchFindAction (Find Next Selection Match, default Cmd+F3/Ctrl+F3) and editor.action.previousSelectionMatchFindAction commands ignore the editor.find.seedSearchStringFromSelection setting. This setting is respected by the Find Widget (Ctrl+F) and other find actions, but not by the Selection Match Find actions.

Steps to Reproduce

  1. Set "editor.find.seedSearchStringFromSelection": "selection" in settings
  2. Select some text (e.g., foo)
  3. Press Cmd+F3 (or the keybinding for editor.action.nextSelectionMatchFindAction) — it correctly finds the next foo
  4. Paste from clipboard to replace the found match
  5. Press Cmd+F3 again

Expected Behavior

With seedSearchStringFromSelection set to "selection", the action should not pick up the word at the cursor when there is no active selection. It should continue searching for the previous search term (foo).

Actual Behavior

The action picks up the word at/near the cursor position and uses that as the new search string, overwriting the previous search term. This is because the SelectionMatchFindAction.run() method hardcodes the call to getSelectionSearchString(editor, 'single', false), always passing false for seedSearchStringFromNonEmptySelection, which enables the word-at-cursor fallback regardless of the user's setting.

Root Cause

In src/vs/editor/contrib/find/browser/findController.ts, SelectionMatchFindAction.run() (line ~918) hardcodes:

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

Compare with StartFindAction (line ~589) which correctly reads the setting:

seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection !== 'never' ? 'single' : 'none',
seedSearchStringFromNonEmptySelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection === 'selection',

Proposed Fix

Make SelectionMatchFindAction.run() respect the editor.find.seedSearchStringFromSelection setting, consistent with how all other find actions handle it. PR incoming.

VS Code Version OS
1.111.0 (latest main) All

Metadata

Metadata

Assignees

Labels

ai-triagedbugIssue identified by VS Code Team member as probable bugconfigVS Code configuration, settingseditor-commandsEditor text manipulation commandseditor-findEditor find operations

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions