提交 826d34e9 编写于 作者: S Sandeep Somavarapu

#67076 Show keybindings

上级 4d6187a5
......@@ -25,6 +25,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import { onUnexpectedError } from 'vs/base/common/errors';
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { Action } from 'vs/base/common/actions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
class MarkerModel {
......@@ -212,7 +213,8 @@ export class MarkerController implements editorCommon.IEditorContribution {
@IMarkerService private readonly _markerService: IMarkerService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@IThemeService private readonly _themeService: IThemeService,
@ICodeEditorService private readonly _editorService: ICodeEditorService
@ICodeEditorService private readonly _editorService: ICodeEditorService,
@IKeybindingService private readonly _keybindingService: IKeybindingService
) {
this._editor = editor;
this._widgetVisible = CONTEXT_MARKERS_NAVIGATION_VISIBLE.bindTo(this._contextKeyService);
......@@ -243,9 +245,11 @@ export class MarkerController implements editorCommon.IEditorContribution {
this._model = new MarkerModel(this._editor, markers);
this._markerService.onMarkerChanged(this._onMarkerChanged, this, this._disposeOnClose);
const prevMarkerKeybinding = this._keybindingService.lookupKeybinding(PrevMarkerAction.ID);
const nextMarkerKeybinding = this._keybindingService.lookupKeybinding(NextMarkerAction.ID);
const actions = [
new Action(PrevMarkerAction.ID, PrevMarkerAction.LABEL, 'show-previous-problem octicon octicon-chevron-up', this._model.canNavigate(), async () => { if (this._model) { this._model.move(false, true); } }),
new Action(NextMarkerAction.ID, NextMarkerAction.LABEL, 'show-next-problem octicon octicon-chevron-down', this._model.canNavigate(), async () => { if (this._model) { this._model.move(true, true); } })
new Action(PrevMarkerAction.ID, PrevMarkerAction.LABEL + (prevMarkerKeybinding ? ` (${prevMarkerKeybinding.getLabel()})` : ''), 'show-previous-problem octicon octicon-chevron-up', this._model.canNavigate(), async () => { if (this._model) { this._model.move(false, true); } }),
new Action(NextMarkerAction.ID, NextMarkerAction.LABEL + (nextMarkerKeybinding ? ` (${nextMarkerKeybinding.getLabel()})` : ''), 'show-next-problem octicon octicon-chevron-down', this._model.canNavigate(), async () => { if (this._model) { this._model.move(true, true); } })
];
this._widget = new MarkerNavigationWidget(this._editor, actions, this._themeService);
this._widgetVisible.set(true);
......@@ -416,7 +420,7 @@ class MarkerNavigationAction extends EditorAction {
}
}
class NextMarkerAction extends MarkerNavigationAction {
export class NextMarkerAction extends MarkerNavigationAction {
static ID: string = 'editor.action.marker.next';
static LABEL: string = nls.localize('markerAction.next.label', "Go to Next Problem (Error, Warning, Info)");
constructor() {
......@@ -424,7 +428,8 @@ class NextMarkerAction extends MarkerNavigationAction {
id: NextMarkerAction.ID,
label: NextMarkerAction.LABEL,
alias: 'Go to Next Error or Warning',
precondition: EditorContextKeys.writable
precondition: EditorContextKeys.writable,
kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Alt | KeyCode.F8, weight: KeybindingWeight.EditorContrib }
});
}
}
......@@ -437,7 +442,8 @@ class PrevMarkerAction extends MarkerNavigationAction {
id: PrevMarkerAction.ID,
label: PrevMarkerAction.LABEL,
alias: 'Go to Previous Error or Warning',
precondition: EditorContextKeys.writable
precondition: EditorContextKeys.writable,
kbOpts: { kbExpr: EditorContextKeys.editorTextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F8, weight: KeybindingWeight.EditorContrib }
});
}
}
......
......@@ -26,6 +26,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { editorHoverBackground, editorHoverBorder, editorHoverHighlight, textCodeBlockBackground, textLinkForeground, editorHoverFooterBackground } from 'vs/platform/theme/common/colorRegistry';
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
export class ModesHoverController implements IEditorContribution {
......@@ -64,6 +65,7 @@ export class ModesHoverController implements IEditorContribution {
@IOpenerService private readonly _openerService: IOpenerService,
@IModeService private readonly _modeService: IModeService,
@IMarkerDecorationsService private readonly _markerDecorationsService: IMarkerDecorationsService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
@IThemeService private readonly _themeService: IThemeService
) {
this._toUnhook = [];
......@@ -207,7 +209,7 @@ export class ModesHoverController implements IEditorContribution {
private _createHoverWidget() {
const renderer = new MarkdownRenderer(this._editor, this._modeService, this._openerService);
this._contentWidget = new ModesContentHoverWidget(this._editor, renderer, this._markerDecorationsService, this._themeService, this._openerService);
this._contentWidget = new ModesContentHoverWidget(this._editor, renderer, this._markerDecorationsService, this._themeService, this._keybindingService, this._openerService);
this._glyphWidget = new ModesGlyphHoverWidget(this._editor, renderer);
}
......
......@@ -29,7 +29,8 @@ import { basename } from 'vs/base/common/resources';
import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IOpenerService, NullOpenerService } from 'vs/platform/opener/common/opener';
import { MarkerController } from 'vs/editor/contrib/gotoError/gotoError';
import { MarkerController, NextMarkerAction } from 'vs/editor/contrib/gotoError/gotoError';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
const $ = dom.$;
......@@ -207,6 +208,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
markdownRenderer: MarkdownRenderer,
markerDecorationsService: IMarkerDecorationsService,
private readonly _themeService: IThemeService,
private readonly _keybindingService: IKeybindingService,
private readonly _openerService: IOpenerService | null = NullOpenerService,
) {
super(ModesContentHoverWidget.ID, editor);
......@@ -510,8 +512,10 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
const actionsElement = dom.append(hoverElement, $('div.actions'));
const disposables: IDisposable[] = [];
const peekMarkerAction = dom.append(actionsElement, $('a.action.peek-marker', { title: nls.localize('go to problem', "Peek Problem") }));
peekMarkerAction.textContent = 'Peek Problem';
const keybinding = this._keybindingService.lookupKeybinding(NextMarkerAction.ID);
const label = nls.localize('peek problem', "Peek Problem") + (keybinding ? ` (${keybinding.getLabel()})` : '');
const peekMarkerAction = dom.append(actionsElement, $('a.action.peek-marker', { title: label }));
peekMarkerAction.textContent = label;
disposables.push(dom.addDisposableListener(peekMarkerAction, dom.EventType.CLICK, e => {
e.stopPropagation();
e.preventDefault();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册