mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -21,7 +21,7 @@ import { IModelDeltaDecoration, TrackedRangeStickiness } from 'vs/editor/common/
|
||||
import { ModelDecorationOptions, TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { Location } from 'vs/editor/common/modes';
|
||||
import { ITextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { AriaProvider, DataSource, Delegate, FileReferencesRenderer, OneReferenceRenderer, TreeElement } from 'vs/editor/contrib/referenceSearch/referencesTree';
|
||||
import { AriaProvider, DataSource, Delegate, FileReferencesRenderer, OneReferenceRenderer, TreeElement, StringRepresentationProvider, IdentityProvider } from 'vs/editor/contrib/referenceSearch/referencesTree';
|
||||
import * as nls from 'vs/nls';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -31,6 +31,10 @@ import { activeContrastBorder, contrastBorder, registerColor } from 'vs/platform
|
||||
import { ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { PeekViewWidget } from './peekViewWidget';
|
||||
import { FileReferences, OneReference, ReferencesModel } from './referencesModel';
|
||||
import { ITreeRenderer, IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
|
||||
import { IAsyncDataTreeOptions } from 'vs/base/browser/ui/tree/asyncDataTree';
|
||||
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
|
||||
import { FuzzyScore } from 'vs/base/common/filters';
|
||||
|
||||
class DecorationsManager implements IDisposable {
|
||||
|
||||
@@ -69,6 +73,9 @@ class DecorationsManager implements IDisposable {
|
||||
}
|
||||
|
||||
private _addDecorations(reference: FileReferences): void {
|
||||
if (!this._editor.hasModel()) {
|
||||
return;
|
||||
}
|
||||
this._callOnModelChange.push(this._editor.getModel().onDidChangeDecorations((event) => this._onDecorationChanged()));
|
||||
|
||||
const newDecorations: IModelDeltaDecoration[] = [];
|
||||
@@ -95,8 +102,13 @@ class DecorationsManager implements IDisposable {
|
||||
private _onDecorationChanged(): void {
|
||||
const toRemove: string[] = [];
|
||||
|
||||
const model = this._editor.getModel();
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._decorations.forEach((reference, decorationId) => {
|
||||
const newRange = this._editor.getModel().getDecorationRange(decorationId);
|
||||
const newRange = model.getDecorationRange(decorationId);
|
||||
|
||||
if (!newRange) {
|
||||
return;
|
||||
@@ -217,7 +229,7 @@ export interface LayoutData {
|
||||
export interface SelectionEvent {
|
||||
kind: 'goto' | 'show' | 'side' | 'open';
|
||||
source: 'editor' | 'tree' | 'title';
|
||||
element: Location;
|
||||
element?: Location;
|
||||
}
|
||||
|
||||
export const ctxReferenceWidgetSearchTreeFocused = new RawContextKey<boolean>('referenceSearchTreeFocused', true);
|
||||
@@ -227,15 +239,14 @@ export const ctxReferenceWidgetSearchTreeFocused = new RawContextKey<boolean>('r
|
||||
*/
|
||||
export class ReferenceWidget extends PeekViewWidget {
|
||||
|
||||
private _model: ReferencesModel;
|
||||
private _model: ReferencesModel | undefined;
|
||||
private _decorationsManager: DecorationsManager;
|
||||
|
||||
private _disposeOnNewModel: IDisposable[] = [];
|
||||
private _callOnDispose: IDisposable[] = [];
|
||||
private _onDidSelectReference = new Emitter<SelectionEvent>();
|
||||
|
||||
private _treeDataSource: DataSource;
|
||||
private _tree: WorkbenchAsyncDataTree<TreeElement>;
|
||||
private _tree: WorkbenchAsyncDataTree<ReferencesModel | FileReferences, TreeElement, FuzzyScore>;
|
||||
private _treeContainer: HTMLElement;
|
||||
private _sash: VSash;
|
||||
private _preview: ICodeEditor;
|
||||
@@ -243,6 +254,8 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
private _previewNotAvailableMessage: TextModel;
|
||||
private _previewContainer: HTMLElement;
|
||||
private _messageContainer: HTMLElement;
|
||||
private height: number | undefined;
|
||||
private width: number | undefined;
|
||||
|
||||
constructor(
|
||||
editor: ICodeEditor,
|
||||
@@ -272,7 +285,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.setModel(null);
|
||||
this.setModel(undefined);
|
||||
this._callOnDispose = dispose(this._callOnDispose);
|
||||
dispose<IDisposable>(this._preview, this._previewNotAvailableMessage, this._tree, this._sash, this._previewModelReference);
|
||||
super.dispose();
|
||||
@@ -330,38 +343,42 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
this._previewNotAvailableMessage = TextModel.createFromString(nls.localize('missingPreviewMessage', "no preview available"));
|
||||
|
||||
// sash
|
||||
this._sash = new VSash(containerElement, this.layoutData.ratio || .8);
|
||||
this._sash = new VSash(containerElement, this.layoutData.ratio || 0.8);
|
||||
this._sash.onDidChangePercentages(() => {
|
||||
let [left, right] = this._sash.percentages;
|
||||
this._previewContainer.style.width = left;
|
||||
this._treeContainer.style.width = right;
|
||||
this._preview.layout();
|
||||
this._tree.layout();
|
||||
this._tree.layout(this.height, this.width && this.width * (1 - this._sash.ratio));
|
||||
this.layoutData.ratio = this._sash.ratio;
|
||||
});
|
||||
|
||||
// tree
|
||||
this._treeContainer = dom.append(containerElement, dom.$('div.ref-tree.inline'));
|
||||
|
||||
const renderer = [
|
||||
const renderers = [
|
||||
this._instantiationService.createInstance(FileReferencesRenderer),
|
||||
this._instantiationService.createInstance(OneReferenceRenderer),
|
||||
];
|
||||
|
||||
const treeOptions = {
|
||||
const treeOptions: IAsyncDataTreeOptions<TreeElement, FuzzyScore> = {
|
||||
ariaLabel: nls.localize('treeAriaLabel', "References"),
|
||||
keyboardSupport: this._defaultTreeKeyboardSupport,
|
||||
accessibilityProvider: new AriaProvider()
|
||||
accessibilityProvider: new AriaProvider(),
|
||||
keyboardNavigationLabelProvider: this._instantiationService.createInstance(StringRepresentationProvider),
|
||||
identityProvider: new IdentityProvider()
|
||||
};
|
||||
|
||||
this._treeDataSource = this._instantiationService.createInstance(DataSource);
|
||||
const treeDataSource = this._instantiationService.createInstance(DataSource);
|
||||
|
||||
this._tree = this._instantiationService.createInstance(
|
||||
WorkbenchAsyncDataTree, this._treeContainer, new Delegate(),
|
||||
renderer as any,
|
||||
this._treeDataSource,
|
||||
this._tree = this._instantiationService.createInstance<HTMLElement, IListVirtualDelegate<TreeElement>, ITreeRenderer<any, FuzzyScore, any>[], IAsyncDataSource<ReferencesModel | FileReferences, TreeElement>, IAsyncDataTreeOptions<TreeElement, FuzzyScore>, WorkbenchAsyncDataTree<ReferencesModel | FileReferences, TreeElement, FuzzyScore>>(
|
||||
WorkbenchAsyncDataTree,
|
||||
this._treeContainer,
|
||||
new Delegate(),
|
||||
renderers,
|
||||
treeDataSource,
|
||||
treeOptions
|
||||
) as any as WorkbenchAsyncDataTree<TreeElement>;
|
||||
);
|
||||
|
||||
ctxReferenceWidgetSearchTreeFocused.bindTo(this._tree.contextKeyService);
|
||||
|
||||
@@ -385,7 +402,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
goto = true;
|
||||
|
||||
} else if (e.browserEvent instanceof MouseEvent) {
|
||||
aside = e.browserEvent.metaKey || e.browserEvent.metaKey || e.browserEvent.altKey;
|
||||
aside = e.browserEvent.ctrlKey || e.browserEvent.metaKey || e.browserEvent.altKey;
|
||||
goto = e.browserEvent.detail === 2;
|
||||
}
|
||||
if (aside) {
|
||||
@@ -403,6 +420,9 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
protected _doLayoutBody(heightInPixel: number, widthInPixel: number): void {
|
||||
super._doLayoutBody(heightInPixel, widthInPixel);
|
||||
|
||||
this.height = heightInPixel;
|
||||
this.width = widthInPixel;
|
||||
|
||||
const height = heightInPixel + 'px';
|
||||
this._sash.height = heightInPixel;
|
||||
this._sash.width = widthInPixel;
|
||||
@@ -414,12 +434,12 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
this._treeContainer.style.height = height;
|
||||
this._treeContainer.style.width = right;
|
||||
// forward
|
||||
this._tree.layout(heightInPixel);
|
||||
this._tree.layout(heightInPixel, widthInPixel * (1 - this._sash.ratio));
|
||||
this._preview.layout();
|
||||
|
||||
// store layout data
|
||||
this.layoutData = {
|
||||
heightInLines: this._viewZone.heightInLines,
|
||||
heightInLines: this._viewZone ? this._viewZone.heightInLines : 0,
|
||||
ratio: this._sash.ratio
|
||||
};
|
||||
}
|
||||
@@ -441,7 +461,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
});
|
||||
}
|
||||
|
||||
public setModel(newModel: ReferencesModel): Thenable<any> {
|
||||
public setModel(newModel: ReferencesModel | undefined): Promise<any> | undefined {
|
||||
// clean up
|
||||
this._disposeOnNewModel = dispose(this._disposeOnNewModel);
|
||||
this._model = newModel;
|
||||
@@ -451,13 +471,16 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private _onNewModel(): Thenable<any> {
|
||||
private _onNewModel(): Promise<any> {
|
||||
if (!this._model) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
if (this._model.empty) {
|
||||
this.setTitle('');
|
||||
this._messageContainer.innerHTML = nls.localize('noResults', "No results");
|
||||
dom.show(this._messageContainer);
|
||||
return Promise.resolve(void 0);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
dom.hide(this._messageContainer);
|
||||
@@ -478,7 +501,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
return;
|
||||
}
|
||||
this._onDidSelectReference.fire({
|
||||
element: { uri: element.uri, range: target.range },
|
||||
element: { uri: element.uri, range: target.range! },
|
||||
kind: (event.ctrlKey || event.metaKey || event.altKey) ? 'side' : 'open',
|
||||
source: 'editor'
|
||||
});
|
||||
@@ -493,11 +516,10 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
this.focus();
|
||||
|
||||
// pick input and a reference to begin with
|
||||
this._treeDataSource.root = this._model.groups.length === 1 ? this._model.groups[0] : this._model;
|
||||
return this._tree.refresh(null);
|
||||
return this._tree.setInput(this._model.groups.length === 1 ? this._model.groups[0] : this._model);
|
||||
}
|
||||
|
||||
private _getFocusedReference(): OneReference {
|
||||
private _getFocusedReference(): OneReference | undefined {
|
||||
const [element] = this._tree.getFocus();
|
||||
if (element instanceof OneReference) {
|
||||
return element;
|
||||
@@ -521,14 +543,14 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
|
||||
// Update widget header
|
||||
if (reference.uri.scheme !== Schemas.inMemory) {
|
||||
this.setTitle(basenameOrAuthority(reference.uri), this._uriLabel.getUriLabel(dirname(reference.uri)));
|
||||
this.setTitle(basenameOrAuthority(reference.uri), this._uriLabel.getUriLabel(dirname(reference.uri)!));
|
||||
} else {
|
||||
this.setTitle(nls.localize('peekView.alternateTitle', "References"));
|
||||
}
|
||||
|
||||
const promise = this._textModelResolverService.createModelReference(reference.uri);
|
||||
|
||||
if (this._treeDataSource.root === reference.parent) {
|
||||
if (this._tree.getInput() === reference.parent) {
|
||||
this._tree.reveal(reference);
|
||||
} else {
|
||||
if (revealParent) {
|
||||
|
||||
Reference in New Issue
Block a user