File tree Expand file tree Collapse file tree
src/vs/editor/contrib/find/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -506,11 +506,21 @@ export class StartFindReplaceAction extends EditorAction {
506506 }
507507
508508 let controller = CommonFindController . get ( editor ) ;
509+ let currentSelection = editor . getSelection ( ) ;
510+ // we only seed search string from selection when the current selection is single line and not empty.
511+ let seedSearchStringFromSelection = currentSelection . isEmpty ( ) ||
512+ currentSelection . startLineNumber !== currentSelection . endLineNumber ;
513+ let oldSearchString = controller . getState ( ) . searchString ;
514+ // if the existing search string in find widget is empty and we don't seed search string from selection, it means the Find Input
515+ // is still empty, so we should focus the Find Input instead of Replace Input.
516+ let shouldFocus = ! oldSearchString && seedSearchStringFromSelection ?
517+ FindStartFocusAction . FocusFindInput : FindStartFocusAction . FocusReplaceInput ;
518+
509519 if ( controller ) {
510520 controller . start ( {
511521 forceRevealReplace : true ,
512- seedSearchStringFromSelection : true ,
513- shouldFocus : FindStartFocusAction . FocusReplaceInput ,
522+ seedSearchStringFromSelection : seedSearchStringFromSelection ,
523+ shouldFocus : shouldFocus ,
514524 shouldAnimate : true
515525 } ) ;
516526 }
You can’t perform that action at this time.
0 commit comments