This commit is contained in:
Johannes Rieken 2018-03-28 11:14:29 +02:00
parent e94f77ab65
commit 66b50b40fe
2 changed files with 33 additions and 7 deletions

View file

@ -206,6 +206,18 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'goToNextReferenceFromEmbeddedEditor',
weight: KeybindingsRegistry.WEIGHT.editorContrib(50),
primary: KeyCode.F4,
when: PeekContext.inPeekEditor,
handler(accessor) {
withController(accessor, controller => {
controller.goToNextOrPreviousReference(true);
});
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'goToPreviousReference',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50),
@ -218,6 +230,18 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'goToPreviousReferenceFromEmbeddedEditor',
weight: KeybindingsRegistry.WEIGHT.editorContrib(50),
primary: KeyMod.Shift | KeyCode.F4,
when: PeekContext.inPeekEditor,
handler(accessor) {
withController(accessor, controller => {
controller.goToNextOrPreviousReference(false);
});
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'closeReferenceSearch',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50),

View file

@ -175,13 +175,15 @@ export class ReferencesController implements editorCommon.IEditorContribution {
}
public async goToNextOrPreviousReference(fwd: boolean) {
let source = this._model.nearestReference(this._editor.getModel().uri, this._widget.position);
let target = this._model.nextOrPreviousReference(source, fwd);
let editorFocus = this._editor.isFocused();
await this._widget.setSelection(target);
await this._gotoReference(target);
if (editorFocus) {
this._editor.focus();
if (this._model) { // can be called while still resolving...
let source = this._model.nearestReference(this._editor.getModel().uri, this._widget.position);
let target = this._model.nextOrPreviousReference(source, fwd);
let editorFocus = this._editor.isFocused();
await this._widget.setSelection(target);
await this._gotoReference(target);
if (editorFocus) {
this._editor.focus();
}
}
}