mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 12:20:29 -04:00
Merge from master
This commit is contained in:
@@ -2,20 +2,19 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { DocumentSymbolProviderRegistry, DocumentSymbolProvider, DocumentSymbol } from 'vs/editor/common/modes';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { fuzzyScore, FuzzyScore } from 'vs/base/common/filters';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { first, size, forEach } from 'vs/base/common/collections';
|
||||
import { isFalsyOrEmpty, binarySearch, coalesce } from 'vs/base/common/arrays';
|
||||
import { commonPrefixLength } from 'vs/base/common/strings';
|
||||
import { IMarker, MarkerSeverity } from 'vs/platform/markers/common/markers';
|
||||
import { onUnexpectedExternalError } from 'vs/base/common/errors';
|
||||
import { LRUCache } from 'vs/base/common/map';
|
||||
import { binarySearch, coalesceInPlace } from 'vs/base/common/arrays';
|
||||
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { first, forEach, size } from 'vs/base/common/collections';
|
||||
import { onUnexpectedExternalError } from 'vs/base/common/errors';
|
||||
import { fuzzyScore, FuzzyScore } from 'vs/base/common/filters';
|
||||
import { LRUCache } from 'vs/base/common/map';
|
||||
import { commonPrefixLength } from 'vs/base/common/strings';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { DocumentSymbol, DocumentSymbolProvider, DocumentSymbolProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { IMarker, MarkerSeverity } from 'vs/platform/markers/common/markers';
|
||||
|
||||
export abstract class TreeElement {
|
||||
|
||||
@@ -134,7 +133,11 @@ export class OutlineGroup extends TreeElement {
|
||||
}
|
||||
|
||||
private _updateMatches(pattern: string, item: OutlineElement, topMatch: OutlineElement): OutlineElement {
|
||||
item.score = fuzzyScore(pattern, item.symbol.name, undefined, true);
|
||||
|
||||
item.score = pattern
|
||||
? fuzzyScore(pattern, pattern.toLowerCase(), 0, item.symbol.name, item.symbol.name.toLowerCase(), 0, true)
|
||||
: [-100, []];
|
||||
|
||||
if (item.score && (!topMatch || item.score[0] > topMatch.score[0])) {
|
||||
topMatch = item;
|
||||
}
|
||||
@@ -143,20 +146,20 @@ export class OutlineGroup extends TreeElement {
|
||||
topMatch = this._updateMatches(pattern, child, topMatch);
|
||||
if (!item.score && child.score) {
|
||||
// don't filter parents with unfiltered children
|
||||
item.score = [0, []];
|
||||
item.score = [-100, []];
|
||||
}
|
||||
}
|
||||
return topMatch;
|
||||
}
|
||||
|
||||
getItemEnclosingPosition(position: IPosition): OutlineElement {
|
||||
return this._getItemEnclosingPosition(position, this.children);
|
||||
return position ? this._getItemEnclosingPosition(position, this.children) : undefined;
|
||||
}
|
||||
|
||||
private _getItemEnclosingPosition(position: IPosition, children: { [id: string]: OutlineElement }): OutlineElement {
|
||||
for (let key in children) {
|
||||
let item = children[key];
|
||||
if (!Range.containsPosition(item.symbol.range, position)) {
|
||||
if (!item.symbol.range || !Range.containsPosition(item.symbol.range, position)) {
|
||||
continue;
|
||||
}
|
||||
return this._getItemEnclosingPosition(position, item.children) || item;
|
||||
@@ -215,7 +218,7 @@ export class OutlineGroup extends TreeElement {
|
||||
};
|
||||
}
|
||||
|
||||
coalesce(markers, true);
|
||||
coalesceInPlace(markers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,10 +301,8 @@ export class OutlineModel extends TreeElement {
|
||||
let group = new OutlineGroup(id, result, provider, index);
|
||||
|
||||
return Promise.resolve(provider.provideDocumentSymbols(result.textModel, token)).then(result => {
|
||||
if (!isFalsyOrEmpty(result)) {
|
||||
for (const info of result) {
|
||||
OutlineModel._makeOutlineElement(info, group);
|
||||
}
|
||||
for (const info of result || []) {
|
||||
OutlineModel._makeOutlineElement(info, group);
|
||||
}
|
||||
return group;
|
||||
}, err => {
|
||||
@@ -393,11 +394,17 @@ export class OutlineModel extends TreeElement {
|
||||
return true;
|
||||
}
|
||||
|
||||
private _matches: [string, OutlineElement];
|
||||
|
||||
updateMatches(pattern: string): OutlineElement {
|
||||
if (this._matches && this._matches[0] === pattern) {
|
||||
return this._matches[1];
|
||||
}
|
||||
let topMatch: OutlineElement;
|
||||
for (const key in this._groups) {
|
||||
topMatch = this._groups[key].updateMatches(pattern, topMatch);
|
||||
}
|
||||
this._matches = [pattern, topMatch];
|
||||
return topMatch;
|
||||
}
|
||||
|
||||
@@ -414,7 +421,7 @@ export class OutlineModel extends TreeElement {
|
||||
}
|
||||
}
|
||||
|
||||
let result: OutlineElement = undefined;
|
||||
let result: OutlineElement | undefined = undefined;
|
||||
for (const key in this._groups) {
|
||||
const group = this._groups[key];
|
||||
result = group.getItemEnclosingPosition(position);
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { createMatches } from 'vs/base/common/filters';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDataSource, IFilter, IRenderer, ISorter, ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import 'vs/css!./media/outlineTree';
|
||||
import 'vs/css!./media/symbol-icons';
|
||||
@@ -97,14 +95,14 @@ export class OutlineDataSource implements IDataSource {
|
||||
return false;
|
||||
}
|
||||
|
||||
getChildren(tree: ITree, element: TreeElement): TPromise<TreeElement[]> {
|
||||
getChildren(tree: ITree, element: TreeElement): Promise<TreeElement[]> {
|
||||
let res = values(element.children);
|
||||
// console.log(element.id + ' with children ' + res.length);
|
||||
return TPromise.wrap(res);
|
||||
return Promise.resolve(res);
|
||||
}
|
||||
|
||||
getParent(tree: ITree, element: TreeElement | any): TPromise<TreeElement> {
|
||||
return TPromise.wrap(element && element.parent);
|
||||
getParent(tree: ITree, element: TreeElement | any): Promise<TreeElement> {
|
||||
return Promise.resolve(element && element.parent);
|
||||
}
|
||||
|
||||
shouldAutoexpand(tree: ITree, element: TreeElement): boolean {
|
||||
@@ -148,13 +146,13 @@ export class OutlineRenderer implements IRenderer {
|
||||
const decoration = dom.$('.outline-element-decoration');
|
||||
dom.addClass(container, 'outline-element');
|
||||
dom.append(container, icon, labelContainer, detail, decoration);
|
||||
return { icon, labelContainer, label: new HighlightedLabel(labelContainer), detail, decoration };
|
||||
return { icon, labelContainer, label: new HighlightedLabel(labelContainer, true), detail, decoration };
|
||||
}
|
||||
if (templateId === 'outline-group') {
|
||||
const labelContainer = dom.$('.outline-element-label');
|
||||
dom.addClass(container, 'outline-element');
|
||||
dom.append(container, labelContainer);
|
||||
return { labelContainer, label: new HighlightedLabel(labelContainer) };
|
||||
return { labelContainer, label: new HighlightedLabel(labelContainer, true) };
|
||||
}
|
||||
|
||||
throw new Error(templateId);
|
||||
@@ -285,7 +283,7 @@ export class OutlineTreeState {
|
||||
static async restore(tree: ITree, state: OutlineTreeState, eventPayload: any): Promise<void> {
|
||||
let model = <OutlineModel>tree.getInput();
|
||||
if (!state || !(model instanceof OutlineModel)) {
|
||||
return TPromise.as(undefined);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
// expansion
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { OutlineElement, OutlineGroup, OutlineModel } from '../outlineModel';
|
||||
import { SymbolKind, DocumentSymbol, DocumentSymbolProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IMarker, MarkerSeverity } from 'vs/platform/markers/common/markers';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
|
||||
suite('OutlineModel', function () {
|
||||
|
||||
Reference in New Issue
Block a user