@@ -51,14 +51,18 @@ import { KeybindingLabel } from 'vs/base/browser/ui/keybindingLabel/keybindingLa
51
51
import { attachListStyler } from 'vs/platform/theme/common/styler' ;
52
52
import { IContextViewService } from 'vs/platform/contextview/browser/contextView' ;
53
53
import { IContextKeyService , RawContextKey , ContextKeyExpr , IContextKey } from 'vs/platform/contextkey/common/contextkey' ;
54
- import { Command } from 'vs/editor/common/editorCommonExtensions' ;
54
+ import { Command , ICommandOptions } from 'vs/editor/common/editorCommonExtensions' ;
55
55
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService' ;
56
56
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
57
57
58
58
/** A context key that is set when an extension editor webview has focus. */
59
59
export const KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS = new RawContextKey < boolean > ( 'extensionEditorWebviewFocus' , undefined ) ;
60
60
/** A context key that is set when an extension editor webview not have focus. */
61
61
export const KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_NOT_FOCUSED : ContextKeyExpr = KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS . toNegated ( ) ;
62
+ /** A context key that is set when the find widget find input in extension editor webview is focused. */
63
+ export const KEYBINDING_CONTEXT_EXTENSIONEDITOR_FIND_WIDGET_INPUT_FOCUSED = new RawContextKey < boolean > ( 'extensionEditorFindWidgetInputFocused' , false ) ;
64
+ /** A context key that is set when the find widget find input in extension editor webview is not focused. */
65
+ export const KEYBINDING_CONTEXT_EXTENSIONEDITOR_FIND_WIDGET_INPUT_NOT_FOCUSED : ContextKeyExpr = KEYBINDING_CONTEXT_EXTENSIONEDITOR_FIND_WIDGET_INPUT_FOCUSED . toNegated ( ) ;
62
66
63
67
function renderBody ( body : string ) : string {
64
68
return `<!DOCTYPE html>
@@ -168,6 +172,7 @@ export class ExtensionEditor extends BaseEditor {
168
172
private extensionDependencies : Cache < IExtensionDependencies > ;
169
173
170
174
private contextKey : IContextKey < boolean > ;
175
+ private findInputFocusContextKey : IContextKey < boolean > ;
171
176
private layoutParticipants : ILayoutParticipant [ ] = [ ] ;
172
177
private contentDisposables : IDisposable [ ] = [ ] ;
173
178
private transientDisposables : IDisposable [ ] = [ ] ;
@@ -199,6 +204,7 @@ export class ExtensionEditor extends BaseEditor {
199
204
this . extensionManifest = null ;
200
205
this . extensionDependencies = null ;
201
206
this . contextKey = KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS . bindTo ( contextKeyService ) ;
207
+ this . findInputFocusContextKey = KEYBINDING_CONTEXT_EXTENSIONEDITOR_FIND_WIDGET_INPUT_FOCUSED . bindTo ( contextKeyService ) ;
202
208
}
203
209
204
210
createEditor ( parent : Builder ) : void {
@@ -346,6 +352,18 @@ export class ExtensionEditor extends BaseEditor {
346
352
}
347
353
}
348
354
355
+ public showNextFindTerm ( ) {
356
+ if ( this . activeWebview ) {
357
+ this . activeWebview . showNextFindTerm ( ) ;
358
+ }
359
+ }
360
+
361
+ public showPreviousFindTerm ( ) {
362
+ if ( this . activeWebview ) {
363
+ this . activeWebview . showPreviousFindTerm ( ) ;
364
+ }
365
+ }
366
+
349
367
private onNavbarChange ( extension : IExtension , id : string ) : void {
350
368
this . contentDisposables = dispose ( this . contentDisposables ) ;
351
369
this . content . innerHTML = '' ;
@@ -366,7 +384,7 @@ export class ExtensionEditor extends BaseEditor {
366
384
. then < void > ( body => {
367
385
const allowedBadgeProviders = this . extensionsWorkbenchService . allowedBadgeProviders ;
368
386
const webViewOptions = allowedBadgeProviders . length > 0 ? { allowScripts : false , allowSvgs : false , svgWhiteList : allowedBadgeProviders } : undefined ;
369
- this . activeWebview = new WebView ( this . content , this . partService . getContainer ( Parts . EDITOR_PART ) , this . contextViewService , this . contextKey , webViewOptions ) ;
387
+ this . activeWebview = new WebView ( this . content , this . partService . getContainer ( Parts . EDITOR_PART ) , this . contextViewService , this . contextKey , this . findInputFocusContextKey , webViewOptions ) ;
370
388
const removeLayoutParticipant = arrays . insert ( this . layoutParticipants , this . activeWebview ) ;
371
389
this . contentDisposables . push ( toDisposable ( removeLayoutParticipant ) ) ;
372
390
@@ -847,3 +865,46 @@ const hideCommand = new ShowExtensionEditorFindCommand({
847
865
}
848
866
} ) ;
849
867
KeybindingsRegistry . registerCommandAndKeybindingRule ( hideCommand . toCommandAndKeybindingRule ( KeybindingsRegistry . WEIGHT . editorContrib ( ) ) ) ;
868
+
869
+ class ShowExtensionEditorFindTermCommand extends Command {
870
+ constructor ( opts : ICommandOptions , private _next : boolean ) {
871
+ super ( opts ) ;
872
+ }
873
+
874
+ public runCommand ( accessor : ServicesAccessor , args : any ) : void {
875
+ const extensionEditor = this . getExtensionEditor ( accessor ) ;
876
+ if ( extensionEditor ) {
877
+ if ( this . _next ) {
878
+ extensionEditor . showNextFindTerm ( ) ;
879
+ } else {
880
+ extensionEditor . showPreviousFindTerm ( ) ;
881
+ }
882
+ }
883
+ }
884
+
885
+ private getExtensionEditor ( accessor : ServicesAccessor ) : ExtensionEditor {
886
+ const activeEditor = accessor . get ( IWorkbenchEditorService ) . getActiveEditor ( ) as ExtensionEditor ;
887
+ if ( activeEditor instanceof ExtensionEditor ) {
888
+ return activeEditor ;
889
+ }
890
+ return null ;
891
+ }
892
+ }
893
+
894
+ const showNextFindTermCommand = new ShowExtensionEditorFindTermCommand ( {
895
+ id : 'editor.action.extensioneditor.showNextFindTerm' ,
896
+ precondition : KEYBINDING_CONTEXT_EXTENSIONEDITOR_FIND_WIDGET_INPUT_FOCUSED ,
897
+ kbOpts : {
898
+ primary : KeyMod . Alt | KeyCode . DownArrow
899
+ }
900
+ } , true ) ;
901
+ KeybindingsRegistry . registerCommandAndKeybindingRule ( showNextFindTermCommand . toCommandAndKeybindingRule ( KeybindingsRegistry . WEIGHT . editorContrib ( ) ) ) ;
902
+
903
+ const showPreviousFindTermCommand = new ShowExtensionEditorFindTermCommand ( {
904
+ id : 'editor.action.extensioneditor.showPreviousFindTerm' ,
905
+ precondition : KEYBINDING_CONTEXT_EXTENSIONEDITOR_FIND_WIDGET_INPUT_FOCUSED ,
906
+ kbOpts : {
907
+ primary : KeyMod . Alt | KeyCode . UpArrow
908
+ }
909
+ } , false ) ;
910
+ KeybindingsRegistry . registerCommandAndKeybindingRule ( showPreviousFindTermCommand . toCommandAndKeybindingRule ( KeybindingsRegistry . WEIGHT . editorContrib ( ) ) ) ;
0 commit comments