-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implement Context scoped history input widget - Adopt to context scoped history input widget
- Loading branch information
Showing
12 changed files
with
125 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; | ||
import { HistoryInputBox, IHistoryInputOptions } from 'vs/base/browser/ui/inputbox/inputBox'; | ||
import { FindInput, IFindInputOptions } from 'vs/base/browser/ui/findinput/findInput'; | ||
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview'; | ||
import { createWidgetScopedContextKeyService, IWidget } from 'vs/platform/widget/browser/widget'; | ||
|
||
export const HistoryInputBoxContext = 'historyInputBox'; | ||
|
||
export class ContextScopedHistoryInputBox extends HistoryInputBox implements IWidget { | ||
|
||
constructor(container: HTMLElement, contextViewProvider: IContextViewProvider, options: IHistoryInputOptions, | ||
@IContextKeyService contextKeyService: IContextKeyService | ||
) { | ||
super(container, contextViewProvider, options); | ||
this._register(createWidgetScopedContextKeyService(contextKeyService, this, HistoryInputBoxContext)); | ||
} | ||
} | ||
|
||
export class ContextScopedFindInput extends FindInput { | ||
|
||
constructor(container: HTMLElement, contextViewProvider: IContextViewProvider, options: IFindInputOptions, | ||
@IContextKeyService contextKeyService: IContextKeyService | ||
) { | ||
super(container, contextViewProvider, options); | ||
this._register(createWidgetScopedContextKeyService(contextKeyService, this.inputBox, HistoryInputBoxContext)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; | ||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; | ||
import { ContextKeyDefinedExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; | ||
import { HistoryInputBoxContext } from 'vs/platform/widget/browser/input'; | ||
import { HistoryInputBox } from 'vs/base/browser/ui/inputbox/inputbox'; | ||
|
||
KeybindingsRegistry.registerCommandAndKeybindingRule({ | ||
id: 'input.action.historyPrevious', | ||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), | ||
when: new ContextKeyDefinedExpr(HistoryInputBoxContext), | ||
primary: KeyMod.Alt | KeyCode.UpArrow, | ||
handler: (accessor, arg2) => { | ||
const historyInputBox: HistoryInputBox = accessor.get(IContextKeyService).getContext(document.activeElement).getValue(HistoryInputBoxContext); | ||
historyInputBox.showPreviousValue(); | ||
} | ||
}); | ||
|
||
KeybindingsRegistry.registerCommandAndKeybindingRule({ | ||
id: 'input.action.historyNext', | ||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), | ||
when: new ContextKeyDefinedExpr(HistoryInputBoxContext), | ||
primary: KeyMod.Alt | KeyCode.DownArrow, | ||
handler: (accessor, arg2) => { | ||
const historyInputBox: HistoryInputBox = accessor.get(IContextKeyService).getContext(document.activeElement).getValue(HistoryInputBoxContext); | ||
historyInputBox.showNextValue(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import { IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; | ||
|
||
export function createWidgetScopedContextKeyService(contextKeyService: IContextKeyService, widget: IWidget, contextKey: string): IContextKeyService { | ||
const result = contextKeyService.createScoped(widget.element); | ||
const widgetContext = new RawContextKey<IWidget>(contextKey, widget); | ||
widgetContext.bindTo(result); | ||
return result; | ||
} | ||
|
||
export interface IWidget { | ||
|
||
readonly element: HTMLElement; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters