提交 b980d895 编写于 作者: J Jackson Kearl

Add keybindings to change number of context lines

Close #92172
上级 45fa807a
......@@ -634,10 +634,17 @@ export class SearchWidget extends Widget {
this._onSearchSubmit.fire({ triggeredOnType, delay });
}
contextLines() {
getContextLines() {
return this.showContextCheckbox.checked ? +this.contextLinesInput.value : 0;
}
modifyContextLines(increase: boolean) {
const current = +this.contextLinesInput.value;
const modified = current + (increase ? 1 : -1);
this.showContextCheckbox.checked = modified !== 0;
this.contextLinesInput.value = '' + modified;
}
toggleContextLines() {
this.showContextCheckbox.checked = !this.showContextCheckbox.checked;
this.onContextLinesChanged();
......
......@@ -13,6 +13,9 @@ export const ToggleSearchEditorCaseSensitiveCommandId = 'toggleSearchEditorCaseS
export const ToggleSearchEditorWholeWordCommandId = 'toggleSearchEditorWholeWord';
export const ToggleSearchEditorRegexCommandId = 'toggleSearchEditorRegex';
export const ToggleSearchEditorContextLinesCommandId = 'toggleSearchEditorContextLines';
export const IncreaseSearchEditorContextLinesCommandId = 'increaseSearchEditorContextLines';
export const DecreaseSearchEditorContextLinesCommandId = 'decreaseSearchEditorContextLines';
export const RerunSearchEditorSearchCommandId = 'rerunSearchEditorSearch';
export const CleanSearchEditorStateCommandId = 'cleanSearchEditorState';
export const SelectAllSearchEditorMatchesCommandId = 'selectAllSearchEditorMatches';
......
......@@ -24,7 +24,7 @@ import { Extensions as EditorInputExtensions, IEditorInputFactory, IEditorInputF
import * as SearchConstants from 'vs/workbench/contrib/search/common/constants';
import * as SearchEditorConstants from 'vs/workbench/contrib/searchEditor/browser/constants';
import { SearchEditor } from 'vs/workbench/contrib/searchEditor/browser/searchEditor';
import { OpenResultsInEditorAction, OpenSearchEditorAction, toggleSearchEditorCaseSensitiveCommand, toggleSearchEditorContextLinesCommand, toggleSearchEditorRegexCommand, toggleSearchEditorWholeWordCommand, selectAllSearchEditorMatchesCommand, RerunSearchEditorSearchAction, OpenSearchEditorToSideAction } from 'vs/workbench/contrib/searchEditor/browser/searchEditorActions';
import { OpenResultsInEditorAction, OpenSearchEditorAction, toggleSearchEditorCaseSensitiveCommand, toggleSearchEditorContextLinesCommand, toggleSearchEditorRegexCommand, toggleSearchEditorWholeWordCommand, selectAllSearchEditorMatchesCommand, RerunSearchEditorSearchAction, OpenSearchEditorToSideAction, modifySearchEditorContextLinesCommand } from 'vs/workbench/contrib/searchEditor/browser/searchEditorActions';
import { getOrMakeSearchEditorInput, SearchEditorInput } from 'vs/workbench/contrib/searchEditor/browser/searchEditorInput';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
......@@ -151,6 +151,24 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_L }
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: SearchEditorConstants.IncreaseSearchEditorContextLinesCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor),
handler: (accessor: ServicesAccessor) => modifySearchEditorContextLinesCommand(accessor, true),
primary: KeyMod.Alt | KeyCode.KEY_L,
mac: { primary: KeyMod.Alt | KeyCode.US_EQUAL }
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: SearchEditorConstants.DecreaseSearchEditorContextLinesCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(SearchEditorConstants.InSearchEditor),
handler: (accessor: ServicesAccessor) => modifySearchEditorContextLinesCommand(accessor, false),
primary: KeyMod.Alt | KeyCode.KEY_L,
mac: { primary: KeyMod.Alt | KeyCode.US_MINUS }
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: SearchEditorConstants.SelectAllSearchEditorMatchesCommandId,
weight: KeybindingWeight.WorkbenchContrib,
......
......@@ -295,6 +295,10 @@ export class SearchEditor extends BaseTextEditor {
this.queryEditorWidget.toggleContextLines();
}
modifyContextLines(increase: boolean) {
this.queryEditorWidget.modifyContextLines(increase);
}
toggleQueryDetails() {
this.toggleIncludesExcludes();
}
......@@ -421,7 +425,7 @@ export class SearchEditor extends BaseTextEditor {
private readConfigFromWidget() {
return {
caseSensitive: this.queryEditorWidget.searchInput.getCaseSensitive(),
contextLines: this.queryEditorWidget.contextLines(),
contextLines: this.queryEditorWidget.getContextLines(),
excludes: this.inputPatternExcludes.getValue(),
includes: this.inputPatternIncludes.getValue(),
query: this.queryEditorWidget.searchInput.getValue(),
......
......@@ -54,6 +54,14 @@ export const toggleSearchEditorContextLinesCommand = (accessor: ServicesAccessor
}
};
export const modifySearchEditorContextLinesCommand = (accessor: ServicesAccessor, increase: boolean) => {
const editorService = accessor.get(IEditorService);
const input = editorService.activeEditor;
if (input instanceof SearchEditorInput) {
(editorService.activeEditorPane as SearchEditor).modifyContextLines(increase);
}
};
export const selectAllSearchEditorMatchesCommand = (accessor: ServicesAccessor) => {
const editorService = accessor.get(IEditorService);
const input = editorService.activeEditor;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册