mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 18:22:34 -05:00
Merge VS Code 1.23.1 (#1520)
This commit is contained in:
@@ -11,7 +11,7 @@ import { Action } from 'vs/base/common/actions';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { $ } from 'vs/base/browser/builder';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { ActionBar, IActionBarOptions } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -133,7 +133,7 @@ export abstract class PeekViewWidget extends ZoneWidget {
|
||||
|
||||
const actionsContainer = $('.peekview-actions').appendTo(this._headElement);
|
||||
const actionBarOptions = this._getActionBarOptions();
|
||||
this._actionbarWidget = new ActionBar(actionsContainer, actionBarOptions);
|
||||
this._actionbarWidget = new ActionBar(actionsContainer.getHTMLElement(), actionBarOptions);
|
||||
this._disposables.push(this._actionbarWidget);
|
||||
|
||||
this._actionbarWidget.push(new Action('peekview.close', nls.localize('label.close', "Close"), 'close-peekview-action', true, () => {
|
||||
|
||||
@@ -68,7 +68,7 @@ export class ReferenceAction extends EditorAction {
|
||||
PeekContext.notInPeekEditor,
|
||||
EditorContextKeys.isInEmbeddedEditor.toNegated()),
|
||||
kbOpts: {
|
||||
kbExpr: EditorContextKeys.textFocus,
|
||||
kbExpr: EditorContextKeys.editorTextFocus,
|
||||
primary: KeyMod.Shift | KeyCode.F12
|
||||
},
|
||||
menuOpts: {
|
||||
@@ -194,6 +194,54 @@ function withController(accessor: ServicesAccessor, fn: (controller: ReferencesC
|
||||
fn(controller);
|
||||
}
|
||||
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'goToNextReference',
|
||||
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(50),
|
||||
primary: KeyCode.F4,
|
||||
when: ctxReferenceSearchVisible,
|
||||
handler(accessor) {
|
||||
withController(accessor, controller => {
|
||||
controller.goToNextOrPreviousReference(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
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),
|
||||
primary: KeyMod.Shift | KeyCode.F4,
|
||||
when: ctxReferenceSearchVisible,
|
||||
handler(accessor) {
|
||||
withController(accessor, controller => {
|
||||
controller.goToNextOrPreviousReference(false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
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),
|
||||
|
||||
@@ -16,7 +16,6 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { ReferencesModel } from './referencesModel';
|
||||
import { ReferenceWidget, LayoutData } from './referencesWidget';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
@@ -34,7 +33,7 @@ export interface RequestOptions {
|
||||
onGoto?: (reference: Location) => TPromise<any>;
|
||||
}
|
||||
|
||||
export class ReferencesController implements editorCommon.IEditorContribution {
|
||||
export abstract class ReferencesController implements editorCommon.IEditorContribution {
|
||||
|
||||
private static readonly ID = 'editor.contrib.referencesController';
|
||||
|
||||
@@ -52,6 +51,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
|
||||
}
|
||||
|
||||
public constructor(
|
||||
private _defaultTreeKeyboardSupport: boolean,
|
||||
editor: ICodeEditor,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IEditorService private readonly _editorService: IEditorService,
|
||||
@@ -103,7 +103,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
|
||||
}));
|
||||
const storageKey = 'peekViewLayout';
|
||||
const data = <LayoutData>JSON.parse(this._storageService.get(storageKey, undefined, '{}'));
|
||||
this._widget = new ReferenceWidget(this._editor, data, this._textModelResolverService, this._contextService, this._themeService, this._instantiationService, this._environmentService);
|
||||
this._widget = new ReferenceWidget(this._editor, this._defaultTreeKeyboardSupport, data, this._textModelResolverService, this._contextService, this._themeService, this._instantiationService, this._environmentService);
|
||||
this._widget.setTitle(nls.localize('labelLoading', "Loading..."));
|
||||
this._widget.show(range);
|
||||
this._disposables.push(this._widget.onDidClose(() => {
|
||||
@@ -155,16 +155,17 @@ export class ReferencesController implements editorCommon.IEditorContribution {
|
||||
|
||||
// show widget
|
||||
return this._widget.setModel(this._model).then(() => {
|
||||
if (this._widget) { // might have been closed
|
||||
// set title
|
||||
this._widget.setMetaTitle(options.getMetaTitle(this._model));
|
||||
|
||||
// set title
|
||||
this._widget.setMetaTitle(options.getMetaTitle(this._model));
|
||||
|
||||
// set 'best' selection
|
||||
let uri = this._editor.getModel().uri;
|
||||
let pos = new Position(range.startLineNumber, range.startColumn);
|
||||
let selection = this._model.nearestReference(uri, pos);
|
||||
if (selection) {
|
||||
return this._widget.setSelection(selection);
|
||||
// set 'best' selection
|
||||
let uri = this._editor.getModel().uri;
|
||||
let pos = new Position(range.startLineNumber, range.startColumn);
|
||||
let selection = this._model.nearestReference(uri, pos);
|
||||
if (selection) {
|
||||
return this._widget.setSelection(selection);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
@@ -174,6 +175,19 @@ export class ReferencesController implements editorCommon.IEditorContribution {
|
||||
});
|
||||
}
|
||||
|
||||
public async goToNextOrPreviousReference(fwd: boolean) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public closeWidget(): void {
|
||||
if (this._widget) {
|
||||
this._widget.dispose();
|
||||
@@ -189,16 +203,16 @@ export class ReferencesController implements editorCommon.IEditorContribution {
|
||||
this._requestIdPool += 1; // Cancel pending requests
|
||||
}
|
||||
|
||||
private _gotoReference(ref: Location): void {
|
||||
private _gotoReference(ref: Location): TPromise<any> {
|
||||
this._widget.hide();
|
||||
|
||||
this._ignoreModelChangeEvent = true;
|
||||
const { uri, range } = ref;
|
||||
const range = Range.lift(ref.range).collapseToStart();
|
||||
|
||||
this._editorService.openEditor({
|
||||
resource: uri,
|
||||
return this._editorService.openEditor({
|
||||
resource: ref.uri,
|
||||
options: { selection: range }
|
||||
}).done(openedEditor => {
|
||||
}).then(openedEditor => {
|
||||
this._ignoreModelChangeEvent = false;
|
||||
|
||||
if (!openedEditor || openedEditor.getControl() !== this._editor) {
|
||||
@@ -235,5 +249,3 @@ export class ReferencesController implements editorCommon.IEditorContribution {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerEditorContribution(ReferencesController);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { basename, dirname } from 'vs/base/common/paths';
|
||||
import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
@@ -253,20 +253,32 @@ export class ReferencesModel implements IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
public nextReference(reference: OneReference): OneReference {
|
||||
public nextOrPreviousReference(reference: OneReference, next: boolean): OneReference {
|
||||
|
||||
var idx = reference.parent.children.indexOf(reference),
|
||||
len = reference.parent.children.length,
|
||||
totalLength = reference.parent.parent.groups.length;
|
||||
let { parent } = reference;
|
||||
|
||||
if (idx + 1 < len || totalLength === 1) {
|
||||
return reference.parent.children[(idx + 1) % len];
|
||||
let idx = parent.children.indexOf(reference);
|
||||
let childCount = parent.children.length;
|
||||
let groupCount = parent.parent.groups.length;
|
||||
|
||||
if (groupCount === 1 || next && idx + 1 < childCount || !next && idx > 0) {
|
||||
// cycling within one file
|
||||
if (next) {
|
||||
idx = (idx + 1) % childCount;
|
||||
} else {
|
||||
idx = (idx + childCount - 1) % childCount;
|
||||
}
|
||||
return parent.children[idx];
|
||||
}
|
||||
|
||||
idx = reference.parent.parent.groups.indexOf(reference.parent);
|
||||
idx = (idx + 1) % totalLength;
|
||||
|
||||
return reference.parent.parent.groups[idx].children[0];
|
||||
idx = parent.parent.groups.indexOf(parent);
|
||||
if (next) {
|
||||
idx = (idx + 1) % groupCount;
|
||||
return parent.parent.groups[idx].children[0];
|
||||
} else {
|
||||
idx = (idx + groupCount - 1) % groupCount;
|
||||
return parent.parent.groups[idx].children[parent.parent.groups[idx].children.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
public nearestReference(resource: URI, position: Position): OneReference {
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'vs/css!./media/referencesWidget';
|
||||
import * as nls from 'vs/nls';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { getPathLabel } from 'vs/base/common/labels';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
@@ -35,7 +35,7 @@ import { FileReferences, OneReference, ReferencesModel } from './referencesModel
|
||||
import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { registerColor, activeContrastBorder, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant, ITheme, IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { attachListStyler, attachBadgeStyler } from 'vs/platform/theme/common/styler';
|
||||
import { attachBadgeStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import URI from 'vs/base/common/uri';
|
||||
@@ -84,28 +84,25 @@ class DecorationsManager implements IDisposable {
|
||||
private _addDecorations(reference: FileReferences): void {
|
||||
this._callOnModelChange.push(this._editor.getModel().onDidChangeDecorations((event) => this._onDecorationChanged()));
|
||||
|
||||
this._editor.changeDecorations(accessor => {
|
||||
const newDecorations: IModelDeltaDecoration[] = [];
|
||||
const newDecorationsActualIndex: number[] = [];
|
||||
|
||||
const newDecorations: IModelDeltaDecoration[] = [];
|
||||
const newDecorationsActualIndex: number[] = [];
|
||||
|
||||
for (let i = 0, len = reference.children.length; i < len; i++) {
|
||||
let oneReference = reference.children[i];
|
||||
if (this._decorationIgnoreSet.has(oneReference.id)) {
|
||||
continue;
|
||||
}
|
||||
newDecorations.push({
|
||||
range: oneReference.range,
|
||||
options: DecorationsManager.DecorationOptions
|
||||
});
|
||||
newDecorationsActualIndex.push(i);
|
||||
for (let i = 0, len = reference.children.length; i < len; i++) {
|
||||
let oneReference = reference.children[i];
|
||||
if (this._decorationIgnoreSet.has(oneReference.id)) {
|
||||
continue;
|
||||
}
|
||||
newDecorations.push({
|
||||
range: oneReference.range,
|
||||
options: DecorationsManager.DecorationOptions
|
||||
});
|
||||
newDecorationsActualIndex.push(i);
|
||||
}
|
||||
|
||||
const decorations = accessor.deltaDecorations([], newDecorations);
|
||||
for (let i = 0; i < decorations.length; i++) {
|
||||
this._decorations.set(decorations[i], reference.children[newDecorationsActualIndex[i]]);
|
||||
}
|
||||
});
|
||||
const decorations = this._editor.deltaDecorations([], newDecorations);
|
||||
for (let i = 0; i < decorations.length; i++) {
|
||||
this._decorations.set(decorations[i], reference.children[newDecorationsActualIndex[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
private _onDecorationChanged(): void {
|
||||
@@ -143,21 +140,19 @@ class DecorationsManager implements IDisposable {
|
||||
}
|
||||
});
|
||||
|
||||
this._editor.changeDecorations((accessor) => {
|
||||
for (let i = 0, len = toRemove.length; i < len; i++) {
|
||||
this._decorations.delete(toRemove[i]);
|
||||
}
|
||||
accessor.deltaDecorations(toRemove, []);
|
||||
});
|
||||
for (let i = 0, len = toRemove.length; i < len; i++) {
|
||||
this._decorations.delete(toRemove[i]);
|
||||
}
|
||||
this._editor.deltaDecorations(toRemove, []);
|
||||
}
|
||||
|
||||
public removeDecorations(): void {
|
||||
this._editor.changeDecorations(accessor => {
|
||||
this._decorations.forEach((value, key) => {
|
||||
accessor.removeDecoration(key);
|
||||
});
|
||||
this._decorations.clear();
|
||||
let toRemove: string[] = [];
|
||||
this._decorations.forEach((value, key) => {
|
||||
toRemove.push(key);
|
||||
});
|
||||
this._editor.deltaDecorations(toRemove, []);
|
||||
this._decorations.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,17 +528,18 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
|
||||
constructor(
|
||||
editor: ICodeEditor,
|
||||
private _defaultTreeKeyboardSupport: boolean,
|
||||
public layoutData: LayoutData,
|
||||
private _textModelResolverService: ITextModelService,
|
||||
private _contextService: IWorkspaceContextService,
|
||||
private _themeService: IThemeService,
|
||||
themeService: IThemeService,
|
||||
private _instantiationService: IInstantiationService,
|
||||
private _environmentService: IEnvironmentService
|
||||
) {
|
||||
super(editor, { showFrame: false, showArrow: true, isResizeable: true, isAccessible: true });
|
||||
|
||||
this._applyTheme(_themeService.getTheme());
|
||||
this._callOnDispose.push(_themeService.onThemeChange(this._applyTheme.bind(this)));
|
||||
this._applyTheme(themeService.getTheme());
|
||||
this._callOnDispose.push(themeService.onThemeChange(this._applyTheme.bind(this)));
|
||||
this.create();
|
||||
}
|
||||
|
||||
@@ -575,7 +571,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
this._tree.DOMFocus();
|
||||
this._tree.domFocus();
|
||||
}
|
||||
|
||||
protected _onTitleClick(e: MouseEvent): void {
|
||||
@@ -635,7 +631,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
|
||||
// tree
|
||||
container.div({ 'class': 'ref-tree inline' }, (div: Builder) => {
|
||||
var controller = this._instantiationService.createInstance(Controller, { clickBehavior: ClickBehavior.ON_MOUSE_UP /* our controller already deals with this */ });
|
||||
var controller = this._instantiationService.createInstance(Controller, { keyboardSupport: this._defaultTreeKeyboardSupport, clickBehavior: ClickBehavior.ON_MOUSE_UP /* our controller already deals with this */ });
|
||||
this._callOnDispose.push(controller);
|
||||
|
||||
var config = <tree.ITreeConfiguration>{
|
||||
@@ -651,7 +647,6 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
};
|
||||
|
||||
this._tree = this._instantiationService.createInstance(WorkbenchTree, div.getHTMLElement(), config, options);
|
||||
this._callOnDispose.push(attachListStyler(this._tree, this._themeService));
|
||||
|
||||
ctxReferenceWidgetSearchTreeFocused.bindTo(this._tree.contextKeyService);
|
||||
|
||||
@@ -659,7 +654,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
var onEvent = (element: any, kind: 'show' | 'goto' | 'side') => {
|
||||
if (element instanceof OneReference) {
|
||||
if (kind === 'show') {
|
||||
this._revealReference(element);
|
||||
this._revealReference(element, false);
|
||||
}
|
||||
this._onDidSelectReference.fire({ element, kind, source: 'tree' });
|
||||
}
|
||||
@@ -711,7 +706,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
}
|
||||
|
||||
public setSelection(selection: OneReference): TPromise<any> {
|
||||
return this._revealReference(selection).then(() => {
|
||||
return this._revealReference(selection, true).then(() => {
|
||||
|
||||
// show in tree
|
||||
this._tree.setSelection([selection]);
|
||||
@@ -781,7 +776,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private _revealReference(reference: OneReference): TPromise<void> {
|
||||
private async _revealReference(reference: OneReference, revealParent: boolean): TPromise<void> {
|
||||
|
||||
// Update widget header
|
||||
if (reference.uri.scheme !== Schemas.inMemory) {
|
||||
@@ -792,6 +787,10 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
|
||||
const promise = this._textModelResolverService.createModelReference(reference.uri);
|
||||
|
||||
if (revealParent) {
|
||||
await this._tree.reveal(reference.parent);
|
||||
}
|
||||
|
||||
return TPromise.join([promise, this._tree.reveal(reference)]).then(values => {
|
||||
const ref = values[0];
|
||||
|
||||
@@ -837,6 +836,7 @@ export const peekViewEditorGutterBackground = registerColor('peekViewEditorGutte
|
||||
|
||||
export const peekViewResultsMatchHighlight = registerColor('peekViewResult.matchHighlightBackground', { dark: '#ea5c004d', light: '#ea5c004d', hc: null }, nls.localize('peekViewResultsMatchHighlight', 'Match highlight color in the peek view result list.'));
|
||||
export const peekViewEditorMatchHighlight = registerColor('peekViewEditor.matchHighlightBackground', { dark: '#ff8f0099', light: '#f5d802de', hc: null }, nls.localize('peekViewEditorMatchHighlight', 'Match highlight color in the peek view editor.'));
|
||||
export const peekViewEditorMatchHighlightBorder = registerColor('peekViewEditor.matchHighlightBorder', { dark: null, light: null, hc: activeContrastBorder }, nls.localize('peekViewEditorMatchHighlightBorder', 'Match highlight border in the peek view editor.'));
|
||||
|
||||
|
||||
registerThemingParticipant((theme, collector) => {
|
||||
@@ -848,10 +848,13 @@ registerThemingParticipant((theme, collector) => {
|
||||
if (referenceHighlightColor) {
|
||||
collector.addRule(`.monaco-editor .reference-zone-widget .preview .reference-decoration { background-color: ${referenceHighlightColor}; }`);
|
||||
}
|
||||
let referenceHighlightBorder = theme.getColor(peekViewEditorMatchHighlightBorder);
|
||||
if (referenceHighlightBorder) {
|
||||
collector.addRule(`.monaco-editor .reference-zone-widget .preview .reference-decoration { border: 2px solid ${referenceHighlightBorder}; box-sizing: border-box; }`);
|
||||
}
|
||||
let hcOutline = theme.getColor(activeContrastBorder);
|
||||
if (hcOutline) {
|
||||
collector.addRule(`.monaco-editor .reference-zone-widget .ref-tree .referenceMatch { border: 1px dotted ${hcOutline}; box-sizing: border-box; }`);
|
||||
collector.addRule(`.monaco-editor .reference-zone-widget .preview .reference-decoration { border: 2px solid ${hcOutline}; box-sizing: border-box; }`);
|
||||
}
|
||||
let resultsBackground = theme.getColor(peekViewResultsBackground);
|
||||
if (resultsBackground) {
|
||||
|
||||
Reference in New Issue
Block a user