提交 648681e6 编写于 作者: J Johannes Rieken

introduce user setting `editor.stablePeek`, #5120

this new setting, which defaults to false, allows to keep peek editors on  double click and ESC. This is useful for serious coding inside peek windows
上级 c67641b5
......@@ -194,13 +194,6 @@ export class MouseTargetFactory {
var t = <Element>e.target;
var path = this.getClassNamePathTo(t, this._viewHelper.viewDomNode);
// Is it a cursor ?
var lineNumberAttribute = t.hasAttribute && t.hasAttribute('lineNumber') ? t.getAttribute('lineNumber') : null;
var columnAttribute = t.hasAttribute && t.hasAttribute('column') ? t.getAttribute('column') : null;
if (lineNumberAttribute && columnAttribute) {
return this.createMouseTargetFromViewCursor(t, parseInt(lineNumberAttribute, 10), parseInt(columnAttribute, 10), mouseColumn);
}
// Is it a content widget?
if (REGEX.IS_CHILD_OF_CONTENT_WIDGETS.test(path) || REGEX.IS_CHILD_OF_OVERFLOWING_CONTENT_WIDGETS.test(path)) {
return this.createMouseTargetFromContentWidgetsChild(t, mouseColumn);
......@@ -211,6 +204,13 @@ export class MouseTargetFactory {
return this.createMouseTargetFromOverlayWidgetsChild(t, mouseColumn);
}
// Is it a cursor ?
var lineNumberAttribute = t.hasAttribute && t.hasAttribute('lineNumber') ? t.getAttribute('lineNumber') : null;
var columnAttribute = t.hasAttribute && t.hasAttribute('column') ? t.getAttribute('column') : null;
if (lineNumberAttribute && columnAttribute) {
return this.createMouseTargetFromViewCursor(t, parseInt(lineNumberAttribute, 10), parseInt(columnAttribute, 10), mouseColumn);
}
// Is it the textarea cover?
if (REGEX.IS_TEXTAREA_COVER.test(path)) {
if (this._context.configuration.editor.viewInfo.glyphMargin) {
......
......@@ -672,10 +672,10 @@ let editorConfiguration:IConfigurationNode = {
'default': DEFAULT_TRIM_AUTO_WHITESPACE,
'description': nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace")
},
'editor.dismissPeekOnEsc' : {
'editor.stablePeek' : {
'type': 'boolean',
'default': true,
'description': nls.localize('dismissPeekOnEsc', "Close peek editor when pressing ESC")
'default': false,
'description': nls.localize('stablePeek', "Do not close peek editors when double clicking their content or when hitting Escape.")
},
'diffEditor.renderSideBySide' : {
'type': 'boolean',
......
......@@ -169,7 +169,7 @@ KeybindingsRegistry.registerCommandDesc({
weight: CommonEditorRegistry.commandWeight(50),
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape],
when: KbExpr.and(KbExpr.has(ctxReferenceSearchVisible), KbExpr.has('config.editor.dismissPeekOnEsc')),
when: KbExpr.and(KbExpr.has(ctxReferenceSearchVisible), KbExpr.not('config.editor.stablePeek')),
handler: closeActiveReferenceSearch
});
......@@ -178,6 +178,6 @@ KeybindingsRegistry.registerCommandDesc({
weight: CommonEditorRegistry.commandWeight(-101),
primary: KeyCode.Escape,
secondary: [KeyMod.Shift | KeyCode.Escape],
when: KbExpr.and(KbExpr.has(ReferenceWidget.INNER_EDITOR_CONTEXT_KEY), KbExpr.has('config.editor.dismissPeekOnEsc')),
when: KbExpr.and(KbExpr.has(ReferenceWidget.INNER_EDITOR_CONTEXT_KEY), KbExpr.not('config.editor.stablePeek')),
handler: closeActiveReferenceSearch
});
......@@ -14,6 +14,7 @@ import {IInstantiationService, optional} from 'vs/platform/instantiation/common/
import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
import {IMessageService} from 'vs/platform/message/common/message';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IConfigurationService, getConfigurationValue} from 'vs/platform/configuration/common/configuration';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IStorageService} from 'vs/platform/storage/common/storage';
import * as editorCommon from 'vs/editor/common/editorCommon';
......@@ -57,6 +58,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
@IInstantiationService private _instantiationService: IInstantiationService,
@IWorkspaceContextService private _contextService: IWorkspaceContextService,
@IStorageService private _storageService: IStorageService,
@IConfigurationService private _configurationService: IConfigurationService,
@optional(IPeekViewService) private _peekViewService: IPeekViewService
) {
this._editor = editor;
......@@ -112,8 +114,15 @@ export class ReferencesController implements editorCommon.IEditorContribution {
this._disposables.push(this._widget.onDidSelectReference(event => {
let {element, kind} = event;
switch (kind) {
case 'side':
case 'open':
if (event.source === 'editor'
&& getConfigurationValue(this._configurationService.getConfiguration(), 'editor.stablePeek', false)) {
// when stable peek is configured we don't close
// the peek window on selecting the editor
break;
}
case 'side':
this._openReference(element, kind === 'side');
break;
case 'goto':
......
......@@ -453,6 +453,7 @@ export interface LayoutData {
export interface SelectionEvent {
kind: 'goto' | 'show' | 'side' | 'open';
source: 'editor' | 'tree' | 'title';
element: OneReference;
}
......@@ -513,7 +514,8 @@ export class ReferenceWidget extends PeekViewWidget {
if (this._preview && this._preview.getModel()) {
this._onDidSelectReference.fire({
element: this._getFocusedReference(),
kind: e.ctrlKey || e.metaKey ? 'side' : 'open'
kind: e.ctrlKey || e.metaKey ? 'side' : 'open',
source: 'title'
});
}
}
......@@ -633,18 +635,18 @@ export class ReferenceWidget extends PeekViewWidget {
this._disposeOnNewModel.push(this._tree.addListener2(Controller.Events.FOCUSED, (element) => {
if (element instanceof OneReference) {
this._revealReference(element);
this._onDidSelectReference.fire({ element, kind: 'show' });
this._onDidSelectReference.fire({ element, kind: 'show', source: 'tree' });
}
}));
this._disposeOnNewModel.push(this._tree.addListener2(Controller.Events.SELECTED, (element: any) => {
if (element instanceof OneReference) {
this._revealReference(element);
this._onDidSelectReference.fire({ element, kind: 'goto' });
this._onDidSelectReference.fire({ element, kind: 'goto', source: 'tree' });
}
}));
this._disposeOnNewModel.push(this._tree.addListener2(Controller.Events.OPEN_TO_SIDE, (element: any) => {
if (element instanceof OneReference) {
this._onDidSelectReference.fire({ element, kind: 'side' });
this._onDidSelectReference.fire({ element, kind: 'side', source: 'tree' });
}
}));
......@@ -653,7 +655,8 @@ export class ReferenceWidget extends PeekViewWidget {
if (e.event.detail === 2) {
this._onDidSelectReference.fire({
element: this._getFocusedReference(),
kind: (e.event.ctrlKey || e.event.metaKey) ? 'side' : 'open'
kind: (e.event.ctrlKey || e.event.metaKey) ? 'side' : 'open',
source: 'editor'
});
}
}));
......
......@@ -39,7 +39,7 @@ export interface IConfigurationServiceEvent {
config: any;
}
export function extractSetting(config: any, settingPath: string): any {
export function getConfigurationValue<T>(config: any, settingPath: string, defaultValue?: T): T {
function accessSetting(config: any, path: string[]): any {
let current = config;
for (let i = 0; i < path.length; i++) {
......@@ -48,9 +48,12 @@ export function extractSetting(config: any, settingPath: string): any {
return undefined;
}
}
return current;
return <T> current;
}
let path = settingPath.split('.');
return accessSetting(config, path);
let result = accessSetting(config, path);
return typeof result === 'undefined'
? defaultValue
: result;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册