Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
@@ -1,10 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M2 5.5L3.05473 4.44428L8 9.38955L12.9453 4.44428L14 5.5L8 11.5L2 5.5Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<rect width="12" height="12" fill="white" transform="translate(2 2)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 351 B |
@@ -1,10 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M2 5.5L3.05473 4.44428L8 9.38955L12.9453 4.44428L14 5.5L8 11.5L2 5.5Z" fill="#4B4B4B"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<rect width="12" height="12" fill="white" transform="translate(2 2)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 353 B |
@@ -1,10 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M2 5.5L3.05473 4.44428L8 9.38955L12.9453 4.44428L14 5.5L8 11.5L2 5.5Z" fill="#C8C8C8"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<rect width="12" height="12" fill="white" transform="translate(2 2)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 353 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.14646 9.76777L8.14644 14.7678L8.85355 14.7678L13.8535 9.76777L13.1464 9.06066L9 13.2071L9 1L8 0.999999L8 13.2071L3.85356 9.06066L3.14646 9.76777Z" fill="#C5C5C5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 319 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.14646 9.76777L8.14644 14.7678L8.85355 14.7678L13.8535 9.76777L13.1464 9.06066L9 13.2071L9 1L8 0.999999L8 13.2071L3.85356 9.06066L3.14646 9.76777Z" fill="#424242"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 319 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.8535 6.2929L8.85356 1.29291H8.14645L3.14645 6.2929L3.85356 7.00001L8 2.85357V15.0607H9V2.85357L13.1464 7.00001L13.8535 6.2929Z" fill="#C5C5C5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 301 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.8535 6.2929L8.85356 1.29291H8.14645L3.14645 6.2929L3.85356 7.00001L8 2.85357V15.0607H9V2.85357L13.1464 7.00001L13.8535 6.2929Z" fill="#424242"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 301 B |
@@ -1,10 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M14 10.5L12.9453 11.5557L8 6.61045L3.05473 11.5557L2 10.5L8 4.5L14 10.5Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<rect width="12" height="12" fill="white" transform="translate(2 2)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 354 B |
@@ -1,10 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M14 10.5L12.9453 11.5557L8 6.61045L3.05473 11.5557L2 10.5L8 4.5L14 10.5Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<rect width="12" height="12" fill="white" transform="translate(2 2)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 354 B |
@@ -1,10 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M14 10.5L12.9453 11.5557L8 6.61045L3.05473 11.5557L2 10.5L8 4.5L14 10.5Z" fill="#4B4B4B"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<rect width="12" height="12" fill="white" transform="translate(2 2)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 356 B |
@@ -1,10 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M14 10.5L12.9453 11.5557L8 6.61045L3.05473 11.5557L2 10.5L8 4.5L14 10.5Z" fill="#C8C8C8"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<rect width="12" height="12" fill="white" transform="translate(2 2)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 356 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.00001 8.70708L11.6465 12.3535L12.3536 11.6464L8.70711 7.99998L12.3536 4.35353L11.6465 3.64642L8.00001 7.29287L4.35356 3.64642L3.64645 4.35353L7.2929 7.99998L3.64645 11.6464L4.35356 12.3535L8.00001 8.70708Z" fill="#C5C5C5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 379 B |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="3 3 16 16" enable-background="new 3 3 16 16"><polygon fill="#e8e8e8" points="12.597,11.042 15.4,13.845 13.844,15.4 11.042,12.598 8.239,15.4 6.683,13.845 9.485,11.042 6.683,8.239 8.238,6.683 11.042,9.486 13.845,6.683 15.4,8.239"/></svg>
|
||||
|
Before Width: | Height: | Size: 307 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.00001 8.70708L11.6465 12.3535L12.3536 11.6464L8.70711 7.99998L12.3536 4.35353L11.6465 3.64642L8.00001 7.29287L4.35356 3.64642L3.64645 4.35353L7.2929 7.99998L3.64645 11.6464L4.35356 12.3535L8.00001 8.70708Z" fill="#424242"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 379 B |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="3 3 16 16" enable-background="new 3 3 16 16"><polygon fill="#424242" points="12.597,11.042 15.4,13.845 13.844,15.4 11.042,12.598 8.239,15.4 6.683,13.845 9.485,11.042 6.683,8.239 8.238,6.683 11.042,9.486 13.845,6.683 15.4,8.239"/></svg>
|
||||
|
Before Width: | Height: | Size: 307 B |
@@ -19,14 +19,6 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.monaco-editor .peekview-widget .head .peekview-title .icon {
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
vertical-align: text-bottom;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.monaco-editor .peekview-widget .head .peekview-title .dirname:not(:empty) {
|
||||
font-size: 0.9em;
|
||||
margin-left: 0.5em;
|
||||
@@ -65,7 +57,7 @@
|
||||
}
|
||||
|
||||
.monaco-editor .peekview-widget .head .peekview-actions .action-label.icon.close-peekview-action {
|
||||
background: url('close.svg') center center no-repeat;
|
||||
background: url('close-light.svg') center center no-repeat;
|
||||
}
|
||||
|
||||
.monaco-editor .peekview-widget > .body {
|
||||
@@ -78,30 +70,23 @@
|
||||
|
||||
.monaco-editor.hc-black .peekview-widget .head .peekview-actions .action-label.icon.close-peekview-action,
|
||||
.monaco-editor.vs-dark .peekview-widget .head .peekview-actions .action-label.icon.close-peekview-action {
|
||||
background: url('close-inverse.svg') center center no-repeat;
|
||||
background: url('close-dark.svg') center center no-repeat;
|
||||
}
|
||||
|
||||
.monaco-editor .peekview-widget .peekview-actions .icon.chevron-up {
|
||||
background: url('chevron-up-inverse.svg') center center no-repeat;
|
||||
}
|
||||
|
||||
.vs-dark .monaco-editor .peekview-widget .peekview-actions .icon.chevron-up {
|
||||
background: url('chevron-up.svg') center center no-repeat;
|
||||
background: url('chevron-previous-light.svg') center center no-repeat;
|
||||
}
|
||||
|
||||
.vs-dark .monaco-editor .peekview-widget .peekview-actions .icon.chevron-up,
|
||||
.hc-black .monaco-editor .peekview-widget .peekview-actions .icon.chevron-up {
|
||||
background: url('chevron-up-inverse-hc.svg') center center no-repeat;
|
||||
background: url('chevron-previous-dark.svg') center center no-repeat;
|
||||
}
|
||||
|
||||
.monaco-editor .peekview-widget .peekview-actions .icon.chevron-down {
|
||||
background: url('chevron-down-inverse.svg') center center no-repeat;
|
||||
}
|
||||
|
||||
.vs-dark .monaco-editor .peekview-widget .peekview-actions .icon.chevron-down {
|
||||
background: url('chevron-down.svg') center center no-repeat;
|
||||
background: url('chevron-next-light.svg') center center no-repeat;
|
||||
}
|
||||
|
||||
.vs-dark .monaco-editor .peekview-widget .peekview-actions .icon.chevron-down,
|
||||
.hc-black .monaco-editor .peekview-widget .peekview-actions .icon.chevron-down {
|
||||
background: url('chevron-down-hc.svg') center center no-repeat;
|
||||
}
|
||||
|
||||
background: url('chevron-next-dark.svg') center center no-repeat;
|
||||
}
|
||||
@@ -85,7 +85,6 @@ export abstract class PeekViewWidget extends ZoneWidget {
|
||||
private _onDidClose = new Emitter<PeekViewWidget>();
|
||||
|
||||
protected _headElement: HTMLDivElement;
|
||||
protected _headingIcon: HTMLElement;
|
||||
protected _primaryHeading: HTMLElement;
|
||||
protected _secondaryHeading: HTMLElement;
|
||||
protected _metaHeading: HTMLElement;
|
||||
@@ -155,18 +154,18 @@ export abstract class PeekViewWidget extends ZoneWidget {
|
||||
dom.append(this._headElement, titleElement);
|
||||
dom.addStandardDisposableListener(titleElement, 'click', event => this._onTitleClick(event));
|
||||
|
||||
this._headingIcon = dom.$('span');
|
||||
this._fillTitleIcon(titleElement);
|
||||
this._primaryHeading = dom.$('span.filename');
|
||||
this._secondaryHeading = dom.$('span.dirname');
|
||||
this._metaHeading = dom.$('span.meta');
|
||||
dom.append(titleElement, this._headingIcon, this._primaryHeading, this._secondaryHeading, this._metaHeading);
|
||||
dom.append(titleElement, this._primaryHeading, this._secondaryHeading, this._metaHeading);
|
||||
|
||||
const actionsContainer = dom.$('.peekview-actions');
|
||||
dom.append(this._headElement, actionsContainer);
|
||||
|
||||
const actionBarOptions = this._getActionBarOptions();
|
||||
this._actionbarWidget = new ActionBar(actionsContainer, actionBarOptions);
|
||||
this._disposables.push(this._actionbarWidget);
|
||||
this._disposables.add(this._actionbarWidget);
|
||||
|
||||
this._actionbarWidget.push(new Action('peekview.close', nls.localize('label.close', "Close"), 'close-peekview-action', true, () => {
|
||||
this.dispose();
|
||||
@@ -174,6 +173,9 @@ export abstract class PeekViewWidget extends ZoneWidget {
|
||||
}), { label: false, icon: true });
|
||||
}
|
||||
|
||||
protected _fillTitleIcon(container: HTMLElement): void {
|
||||
}
|
||||
|
||||
protected _getActionBarOptions(): IActionBarOptions {
|
||||
return {};
|
||||
}
|
||||
@@ -182,10 +184,6 @@ export abstract class PeekViewWidget extends ZoneWidget {
|
||||
// implement me
|
||||
}
|
||||
|
||||
public setTitleIcon(iconClassName: string): void {
|
||||
this._headingIcon.className = iconClassName ? `icon ${iconClassName}` : '';
|
||||
}
|
||||
|
||||
public setTitle(primaryHeading: string, secondaryHeading?: string): void {
|
||||
this._primaryHeading.innerHTML = strings.escape(primaryHeading);
|
||||
this._primaryHeading.setAttribute('aria-label', primaryHeading);
|
||||
|
||||
@@ -61,7 +61,7 @@ export class ReferenceAction extends EditorAction {
|
||||
super({
|
||||
id: 'editor.action.referenceSearch.trigger',
|
||||
label: nls.localize('references.action.label', "Peek References"),
|
||||
alias: 'Find All References', // leave the alias?
|
||||
alias: 'Peek References',
|
||||
precondition: ContextKeyExpr.and(
|
||||
EditorContextKeys.hasReferenceProvider,
|
||||
PeekContext.notInPeekEditor,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { dispose, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
@@ -32,11 +32,11 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
|
||||
|
||||
private static readonly ID = 'editor.contrib.referencesController';
|
||||
|
||||
private readonly _disposables = new DisposableStore();
|
||||
private readonly _editor: ICodeEditor;
|
||||
private _widget: ReferenceWidget | null;
|
||||
private _model: ReferencesModel | null;
|
||||
private _requestIdPool = 0;
|
||||
private _disposables: IDisposable[] = [];
|
||||
private _ignoreModelChangeEvent = false;
|
||||
|
||||
private readonly _referenceSearchVisible: IContextKey<boolean>;
|
||||
@@ -91,8 +91,8 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
|
||||
this._referenceSearchVisible.set(true);
|
||||
|
||||
// close the widget on model/mode changes
|
||||
this._disposables.push(this._editor.onDidChangeModelLanguage(() => { this.closeWidget(); }));
|
||||
this._disposables.push(this._editor.onDidChangeModel(() => {
|
||||
this._disposables.add(this._editor.onDidChangeModelLanguage(() => { this.closeWidget(); }));
|
||||
this._disposables.add(this._editor.onDidChangeModel(() => {
|
||||
if (!this._ignoreModelChangeEvent) {
|
||||
this.closeWidget();
|
||||
}
|
||||
@@ -103,7 +103,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
|
||||
this._widget.setTitle(nls.localize('labelLoading', "Loading..."));
|
||||
this._widget.show(range);
|
||||
|
||||
this._disposables.push(this._widget.onDidClose(() => {
|
||||
this._disposables.add(this._widget.onDidClose(() => {
|
||||
modelPromise.cancel();
|
||||
if (this._widget) {
|
||||
this._storageService.store(storageKey, JSON.stringify(this._widget.layoutData), StorageScope.GLOBAL);
|
||||
@@ -112,7 +112,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
|
||||
this.closeWidget();
|
||||
}));
|
||||
|
||||
this._disposables.push(this._widget.onDidSelectReference(event => {
|
||||
this._disposables.add(this._widget.onDidSelectReference(event => {
|
||||
let { element, kind } = event;
|
||||
switch (kind) {
|
||||
case 'open':
|
||||
@@ -205,7 +205,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
|
||||
this._widget = null;
|
||||
}
|
||||
this._referenceSearchVisible.reset();
|
||||
this._disposables = dispose(this._disposables);
|
||||
this._disposables.clear();
|
||||
if (this._model) {
|
||||
dispose(this._model);
|
||||
this._model = null;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { localize } from 'vs/nls';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
import { IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, IReference, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { defaultGenerator } from 'vs/base/common/idGenerator';
|
||||
@@ -14,6 +14,7 @@ import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { Location, LocationLink } from 'vs/editor/common/modes';
|
||||
import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IMatch } from 'vs/base/common/filters';
|
||||
|
||||
export class OneReference {
|
||||
readonly id: string;
|
||||
@@ -61,7 +62,7 @@ export class FilePreview implements IDisposable {
|
||||
dispose(this._modelReference);
|
||||
}
|
||||
|
||||
preview(range: IRange, n: number = 8): { before: string; inside: string; after: string } | undefined {
|
||||
preview(range: IRange, n: number = 8): { value: string; highlight: IMatch } | undefined {
|
||||
const model = this._modelReference.object.textEditorModel;
|
||||
|
||||
if (!model) {
|
||||
@@ -73,13 +74,14 @@ export class FilePreview implements IDisposable {
|
||||
const beforeRange = new Range(startLineNumber, word.startColumn, startLineNumber, startColumn);
|
||||
const afterRange = new Range(endLineNumber, endColumn, endLineNumber, Number.MAX_VALUE);
|
||||
|
||||
const ret = {
|
||||
before: model.getValueInRange(beforeRange).replace(/^\s+/, strings.empty),
|
||||
inside: model.getValueInRange(range),
|
||||
after: model.getValueInRange(afterRange).replace(/\s+$/, strings.empty)
|
||||
};
|
||||
const before = model.getValueInRange(beforeRange).replace(/^\s+/, strings.empty);
|
||||
const inside = model.getValueInRange(range);
|
||||
const after = model.getValueInRange(afterRange).replace(/\s+$/, strings.empty);
|
||||
|
||||
return ret;
|
||||
return {
|
||||
value: before + inside + after,
|
||||
highlight: { start: before.length, end: before.length + inside.length }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +166,7 @@ export class FileReferences implements IDisposable {
|
||||
|
||||
export class ReferencesModel implements IDisposable {
|
||||
|
||||
private readonly _disposables: IDisposable[];
|
||||
private readonly _disposables = new DisposableStore();
|
||||
readonly groups: FileReferences[] = [];
|
||||
readonly references: OneReference[] = [];
|
||||
|
||||
@@ -172,7 +174,7 @@ export class ReferencesModel implements IDisposable {
|
||||
readonly onDidChangeReferenceRange: Event<OneReference> = this._onDidChangeReferenceRange.event;
|
||||
|
||||
constructor(references: LocationLink[]) {
|
||||
this._disposables = [];
|
||||
|
||||
// grouping and sorting
|
||||
const [providersFirst] = references;
|
||||
references.sort(ReferencesModel._compareReferences);
|
||||
@@ -190,7 +192,7 @@ export class ReferencesModel implements IDisposable {
|
||||
|| !Range.equalsRange(ref.range, current.children[current.children.length - 1].range)) {
|
||||
|
||||
let oneRef = new OneReference(current, ref.targetSelectionRange || ref.range, providersFirst === ref);
|
||||
this._disposables.push(oneRef.onRefChanged((e) => this._onDidChangeReferenceRange.fire(e)));
|
||||
this._disposables.add(oneRef.onRefChanged((e) => this._onDidChangeReferenceRange.fire(e)));
|
||||
this.references.push(oneRef);
|
||||
current.children.push(oneRef);
|
||||
}
|
||||
@@ -280,9 +282,8 @@ export class ReferencesModel implements IDisposable {
|
||||
|
||||
dispose(): void {
|
||||
dispose(this.groups);
|
||||
dispose(this._disposables);
|
||||
this._disposables.dispose();
|
||||
this.groups.length = 0;
|
||||
this._disposables.length = 0;
|
||||
}
|
||||
|
||||
private static _compareReferences(a: Location, b: Location): number {
|
||||
|
||||
@@ -15,7 +15,6 @@ import * as dom from 'vs/base/browser/dom';
|
||||
import { localize } from 'vs/nls';
|
||||
import { getBaseLabel } from 'vs/base/common/labels';
|
||||
import { dirname, basename } from 'vs/base/common/resources';
|
||||
import { escape } from 'vs/base/common/strings';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
|
||||
@@ -23,6 +22,7 @@ import { IListVirtualDelegate, IKeyboardNavigationLabelProvider, IIdentityProvid
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { FuzzyScore, createMatches, IMatch } from 'vs/base/common/filters';
|
||||
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
|
||||
|
||||
//#region data source
|
||||
|
||||
@@ -82,8 +82,14 @@ export class StringRepresentationProvider implements IKeyboardNavigationLabelPro
|
||||
constructor(@IKeybindingService private readonly _keybindingService: IKeybindingService) { }
|
||||
|
||||
getKeyboardNavigationLabel(element: TreeElement): { toString(): string; } {
|
||||
// todo@joao `OneReference` elements are lazy and their "real" label
|
||||
// isn't known yet
|
||||
if (element instanceof OneReference) {
|
||||
const { preview } = element.parent;
|
||||
const parts = preview && preview.preview(element.range);
|
||||
if (parts) {
|
||||
return parts.value;
|
||||
}
|
||||
}
|
||||
// FileReferences or unresolved OneReference
|
||||
return basename(element.uri);
|
||||
}
|
||||
|
||||
@@ -161,31 +167,29 @@ export class FileReferencesRenderer implements ITreeRenderer<FileReferences, Fuz
|
||||
//#region render: Reference
|
||||
class OneReferenceTemplate {
|
||||
|
||||
readonly before: HTMLSpanElement;
|
||||
readonly inside: HTMLSpanElement;
|
||||
readonly after: HTMLSpanElement;
|
||||
readonly label: HighlightedLabel;
|
||||
|
||||
constructor(container: HTMLElement) {
|
||||
const parent = document.createElement('div');
|
||||
this.before = document.createElement('span');
|
||||
this.inside = document.createElement('span');
|
||||
this.after = document.createElement('span');
|
||||
dom.addClass(this.inside, 'referenceMatch');
|
||||
dom.addClass(parent, 'reference');
|
||||
parent.appendChild(this.before);
|
||||
parent.appendChild(this.inside);
|
||||
parent.appendChild(this.after);
|
||||
container.appendChild(parent);
|
||||
this.label = new HighlightedLabel(container, false);
|
||||
}
|
||||
|
||||
set(element: OneReference): void {
|
||||
set(element: OneReference, score?: FuzzyScore): void {
|
||||
const filePreview = element.parent.preview;
|
||||
const preview = filePreview && filePreview.preview(element.range);
|
||||
if (preview) {
|
||||
const { before, inside, after } = preview;
|
||||
this.before.innerHTML = escape(before);
|
||||
this.inside.innerHTML = escape(inside);
|
||||
this.after.innerHTML = escape(after);
|
||||
if (!preview) {
|
||||
// this means we FAILED to resolve the document...
|
||||
this.label.set(`${basename(element.uri)}:${element.range.startLineNumber + 1}:${element.range.startColumn + 1}`);
|
||||
} else {
|
||||
// render search match as highlight unless
|
||||
// we have score, then render the score
|
||||
const { value, highlight } = preview;
|
||||
if (score && !FuzzyScore.isDefault(score)) {
|
||||
dom.toggleClass(this.label.element, 'referenceMatch', false);
|
||||
this.label.set(value, createMatches(score));
|
||||
} else {
|
||||
dom.toggleClass(this.label.element, 'referenceMatch', true);
|
||||
this.label.set(value, [highlight]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,11 +203,10 @@ export class OneReferenceRenderer implements ITreeRenderer<OneReference, FuzzySc
|
||||
renderTemplate(container: HTMLElement): OneReferenceTemplate {
|
||||
return new OneReferenceTemplate(container);
|
||||
}
|
||||
renderElement(element: ITreeNode<OneReference, FuzzyScore>, index: number, templateData: OneReferenceTemplate): void {
|
||||
templateData.set(element.element);
|
||||
renderElement(node: ITreeNode<OneReference, FuzzyScore>, index: number, templateData: OneReferenceTemplate): void {
|
||||
templateData.set(node.element, node.filterData);
|
||||
}
|
||||
disposeTemplate(): void {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { IMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { Orientation } from 'vs/base/browser/ui/sash/sash';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { dispose, IDisposable, IReference } from 'vs/base/common/lifecycle';
|
||||
import { dispose, IDisposable, IReference, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { basenameOrAuthority, dirname } from 'vs/base/common/resources';
|
||||
import 'vs/css!./media/referencesWidget';
|
||||
@@ -47,22 +47,22 @@ class DecorationsManager implements IDisposable {
|
||||
|
||||
private _decorations = new Map<string, OneReference>();
|
||||
private _decorationIgnoreSet = new Set<string>();
|
||||
private _callOnDispose: IDisposable[] = [];
|
||||
private _callOnModelChange: IDisposable[] = [];
|
||||
private readonly _callOnDispose = new DisposableStore();
|
||||
private readonly _callOnModelChange = new DisposableStore();
|
||||
|
||||
constructor(private _editor: ICodeEditor, private _model: ReferencesModel) {
|
||||
this._callOnDispose.push(this._editor.onDidChangeModel(() => this._onModelChanged()));
|
||||
this._callOnDispose.add(this._editor.onDidChangeModel(() => this._onModelChanged()));
|
||||
this._onModelChanged();
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._callOnModelChange = dispose(this._callOnModelChange);
|
||||
this._callOnDispose = dispose(this._callOnDispose);
|
||||
this._callOnModelChange.dispose();
|
||||
this._callOnDispose.dispose();
|
||||
this.removeDecorations();
|
||||
}
|
||||
|
||||
private _onModelChanged(): void {
|
||||
this._callOnModelChange = dispose(this._callOnModelChange);
|
||||
this._callOnModelChange.clear();
|
||||
const model = this._editor.getModel();
|
||||
if (model) {
|
||||
for (const ref of this._model.groups) {
|
||||
@@ -78,7 +78,7 @@ class DecorationsManager implements IDisposable {
|
||||
if (!this._editor.hasModel()) {
|
||||
return;
|
||||
}
|
||||
this._callOnModelChange.push(this._editor.getModel().onDidChangeDecorations((event) => this._onDecorationChanged()));
|
||||
this._callOnModelChange.add(this._editor.getModel().onDidChangeDecorations((event) => this._onDecorationChanged()));
|
||||
|
||||
const newDecorations: IModelDeltaDecoration[] = [];
|
||||
const newDecorationsActualIndex: number[] = [];
|
||||
@@ -194,8 +194,8 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
private _model: ReferencesModel | undefined;
|
||||
private _decorationsManager: DecorationsManager;
|
||||
|
||||
private _disposeOnNewModel: IDisposable[] = [];
|
||||
private _callOnDispose: IDisposable[] = [];
|
||||
private readonly _disposeOnNewModel = new DisposableStore();
|
||||
private readonly _callOnDispose = new DisposableStore();
|
||||
private _onDidSelectReference = new Emitter<SelectionEvent>();
|
||||
|
||||
private _tree: WorkbenchAsyncDataTree<ReferencesModel | FileReferences, TreeElement, FuzzyScore>;
|
||||
@@ -222,15 +222,19 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
super(editor, { showFrame: false, showArrow: true, isResizeable: true, isAccessible: true });
|
||||
|
||||
this._applyTheme(themeService.getTheme());
|
||||
this._callOnDispose.push(themeService.onThemeChange(this._applyTheme.bind(this)));
|
||||
this._callOnDispose.add(themeService.onThemeChange(this._applyTheme.bind(this)));
|
||||
this._peekViewService.addExclusiveWidget(editor, this);
|
||||
this.create();
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.setModel(undefined);
|
||||
this._callOnDispose = dispose(this._callOnDispose);
|
||||
dispose<IDisposable>(this._preview, this._previewNotAvailableMessage, this._tree, this._previewModelReference);
|
||||
this._callOnDispose.dispose();
|
||||
this._disposeOnNewModel.dispose();
|
||||
dispose(this._preview);
|
||||
dispose(this._previewNotAvailableMessage);
|
||||
dispose(this._tree);
|
||||
dispose(this._previewModelReference);
|
||||
this._splitView.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -344,11 +348,11 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
}
|
||||
}, Sizing.Distribute);
|
||||
|
||||
this._splitView.onDidSashChange(() => {
|
||||
this._disposables.add(this._splitView.onDidSashChange(() => {
|
||||
if (this._dim.width) {
|
||||
this.layoutData.ratio = this._splitView.getViewSize(0) / this._dim.width;
|
||||
}
|
||||
}, undefined, this._disposables);
|
||||
}, undefined));
|
||||
|
||||
// listen on selection and focus
|
||||
let onEvent = (element: any, kind: 'show' | 'goto' | 'side') => {
|
||||
@@ -421,7 +425,7 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
|
||||
public setModel(newModel: ReferencesModel | undefined): Promise<any> {
|
||||
// clean up
|
||||
this._disposeOnNewModel = dispose(this._disposeOnNewModel);
|
||||
this._disposeOnNewModel.clear();
|
||||
this._model = newModel;
|
||||
if (this._model) {
|
||||
return this._onNewModel();
|
||||
@@ -443,13 +447,13 @@ export class ReferenceWidget extends PeekViewWidget {
|
||||
|
||||
dom.hide(this._messageContainer);
|
||||
this._decorationsManager = new DecorationsManager(this._preview, this._model);
|
||||
this._disposeOnNewModel.push(this._decorationsManager);
|
||||
this._disposeOnNewModel.add(this._decorationsManager);
|
||||
|
||||
// listen on model changes
|
||||
this._disposeOnNewModel.push(this._model.onDidChangeReferenceRange(reference => this._tree.rerender(reference)));
|
||||
this._disposeOnNewModel.add(this._model.onDidChangeReferenceRange(reference => this._tree.rerender(reference)));
|
||||
|
||||
// listen on editor
|
||||
this._disposeOnNewModel.push(this._preview.onMouseDown(e => {
|
||||
this._disposeOnNewModel.add(this._preview.onMouseDown(e => {
|
||||
const { event, target } = e;
|
||||
if (event.detail !== 2) {
|
||||
return;
|
||||
@@ -566,7 +570,7 @@ export const peekViewEditorMatchHighlightBorder = registerColor('peekViewEditor.
|
||||
registerThemingParticipant((theme, collector) => {
|
||||
const findMatchHighlightColor = theme.getColor(peekViewResultsMatchHighlight);
|
||||
if (findMatchHighlightColor) {
|
||||
collector.addRule(`.monaco-editor .reference-zone-widget .ref-tree .referenceMatch { background-color: ${findMatchHighlightColor}; }`);
|
||||
collector.addRule(`.monaco-editor .reference-zone-widget .ref-tree .referenceMatch .highlight { background-color: ${findMatchHighlightColor}; }`);
|
||||
}
|
||||
const referenceHighlightColor = theme.getColor(peekViewEditorMatchHighlight);
|
||||
if (referenceHighlightColor) {
|
||||
@@ -578,7 +582,7 @@ registerThemingParticipant((theme, collector) => {
|
||||
}
|
||||
const 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 .ref-tree .referenceMatch .highlight { border: 1px dotted ${hcOutline}; box-sizing: border-box; }`);
|
||||
}
|
||||
const resultsBackground = theme.getColor(peekViewResultsBackground);
|
||||
if (resultsBackground) {
|
||||
|
||||