@@ -14,7 +14,7 @@ import { Selection } from 'vs/editor/common/core/selection';
14
14
import * as strings from 'vs/base/common/strings' ;
15
15
import * as editorCommon from 'vs/editor/common/editorCommon' ;
16
16
import { editorAction , commonEditorContribution , ServicesAccessor , EditorAction , EditorCommand , CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions' ;
17
- import { FIND_IDS , FindModelBoundToEditorModel , ToggleCaseSensitiveKeybinding , ToggleRegexKeybinding , ToggleWholeWordKeybinding , ShowPreviousFindTermKeybinding , ShowNextFindTermKeybinding } from 'vs/editor/contrib/find/common/findModel' ;
17
+ import { FIND_IDS , FindModelBoundToEditorModel , ToggleCaseSensitiveKeybinding , ToggleRegexKeybinding , ToggleWholeWordKeybinding , ToggleSearchScopeKeybinding , ShowPreviousFindTermKeybinding , ShowNextFindTermKeybinding } from 'vs/editor/contrib/find/common/findModel' ;
18
18
import { FindReplaceState , FindReplaceStateChangedEvent , INewFindReplaceState } from 'vs/editor/contrib/find/common/findState' ;
19
19
import { DocumentHighlightProviderRegistry } from 'vs/editor/common/modes' ;
20
20
import { RunOnceScheduler , Delayer } from 'vs/base/common/async' ;
@@ -153,6 +153,20 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
153
153
this . _state . change ( { isRegex : ! this . _state . isRegex } , false ) ;
154
154
}
155
155
156
+ public toggleSearchScope ( ) : void {
157
+ if ( this . _state . searchScope ) {
158
+ this . _state . change ( { searchScope : null } , true ) ;
159
+ } else {
160
+ let selection = this . _editor . getSelection ( ) ;
161
+ if ( selection . endColumn === 1 && selection . endLineNumber > selection . startLineNumber ) {
162
+ selection = selection . setEndPosition ( selection . endLineNumber - 1 , 1 ) ;
163
+ }
164
+ if ( ! selection . isEmpty ( ) ) {
165
+ this . _state . change ( { searchScope : selection } , true ) ;
166
+ }
167
+ }
168
+ }
169
+
156
170
public setSearchString ( searchString : string ) : void {
157
171
this . _state . change ( { searchString : searchString } , false ) ;
158
172
}
@@ -1064,6 +1078,20 @@ CommonEditorRegistry.registerEditorCommand(new FindCommand({
1064
1078
}
1065
1079
} ) ) ;
1066
1080
1081
+ CommonEditorRegistry . registerEditorCommand ( new FindCommand ( {
1082
+ id : FIND_IDS . ToggleSearchScopeCommand ,
1083
+ precondition : null ,
1084
+ handler : x => x . toggleSearchScope ( ) ,
1085
+ kbOpts : {
1086
+ weight : CommonEditorRegistry . commandWeight ( 5 ) ,
1087
+ kbExpr : EditorContextKeys . focus ,
1088
+ primary : ToggleSearchScopeKeybinding . primary ,
1089
+ mac : ToggleSearchScopeKeybinding . mac ,
1090
+ win : ToggleSearchScopeKeybinding . win ,
1091
+ linux : ToggleSearchScopeKeybinding . linux
1092
+ }
1093
+ } ) ) ;
1094
+
1067
1095
CommonEditorRegistry . registerEditorCommand ( new FindCommand ( {
1068
1096
id : FIND_IDS . ReplaceOneAction ,
1069
1097
precondition : CONTEXT_FIND_WIDGET_VISIBLE ,
0 commit comments