Skip to content

Commit

Permalink
switch to using TextResourceConfigurationService to account for confi…
Browse files Browse the repository at this point in the history
…guration overides when reading breadcrumb configurations involving filteredTypes
  • Loading branch information
petevdp committed Nov 19, 2019
1 parent 1420884 commit 9d9a99d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
9 changes: 8 additions & 1 deletion src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { onDidChangeZoomLevel } from 'vs/base/browser/browser';
import { withNullAsUndefined, withUndefinedAsNull } from 'vs/base/common/types';
import { ILabelService } from 'vs/platform/label/common/label';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';

class Item extends BreadcrumbsItem {

Expand Down Expand Up @@ -168,6 +169,7 @@ export class BreadcrumbsControl {
@IThemeService private readonly _themeService: IThemeService,
@IQuickOpenService private readonly _quickOpenService: IQuickOpenService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ITextResourceConfigurationService private readonly _textResourceConfigurationService: ITextResourceConfigurationService,
@IFileService private readonly _fileService: IFileService,
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@ILabelService private readonly _labelService: ILabelService,
Expand Down Expand Up @@ -246,7 +248,12 @@ export class BreadcrumbsControl {

const uri = input.getResource()!;
const editor = this._getActiveCodeEditor();
const model = new EditorBreadcrumbsModel(uri, editor, this._configurationService, this._workspaceService);
const model = new EditorBreadcrumbsModel(
uri, editor,
this._configurationService,
this._textResourceConfigurationService,
this._workspaceService
);
dom.toggleClass(this.domNode, 'relative-path', model.isRelative());
dom.toggleClass(this.domNode, 'backslash-path', this._labelService.getSeparator(uri.scheme, uri.authority) === '\\');

Expand Down
13 changes: 5 additions & 8 deletions src/vs/workbench/browser/parts/editor/breadcrumbsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { FileKind } from 'vs/platform/files/common/files';
import { withNullAsUndefined } from 'vs/base/common/types';
import { OutlineFilter } from 'vs/editor/contrib/documentSymbols/outlineTree';
import { ITextModel } from 'vs/editor/common/model';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';

export class FileElement {
constructor(
Expand Down Expand Up @@ -54,9 +55,9 @@ export class EditorBreadcrumbsModel {
private readonly _uri: URI,
private readonly _editor: ICodeEditor | undefined,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ITextResourceConfigurationService private readonly _textResourceConfigurationService: ITextResourceConfigurationService,
@IWorkspaceContextService workspaceService: IWorkspaceContextService,
) {

this._cfgFilePath = BreadcrumbsConfig.FilePath.bindTo(_configurationService);
this._cfgSymbolPath = BreadcrumbsConfig.SymbolPath.bindTo(_configurationService);

Expand Down Expand Up @@ -261,16 +262,12 @@ export class EditorBreadcrumbsModel {
private _isFiltered(element: TreeElement): boolean {
if (element instanceof OutlineElement) {
const key = `breadcrumbs.${OutlineFilter.kindToConfigName[element.symbol.kind]}`;

// If possible, look for language specific overrides when reading configuration.
let uri: URI | undefined;
if (this._editor && this._editor.getModel()) {
const model = this._editor.getModel() as ITextModel;
return !this._configurationService.getValue<boolean>(key, {
overrideIdentifier: model.getLanguageIdentifier().language
});
uri = model.uri;
}

return this._configurationService.getValue<boolean>(key);
return !this._textResourceConfigurationService.getValue<boolean>(uri, key);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ suite('Breadcrumb Model', function () {

test('only uri, inside workspace', function () {

let model = new EditorBreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/path/file.ts'), undefined, configService, workspaceService);
let model = new EditorBreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/path/file.ts'), undefined, configService, configService, workspaceService);
let elements = model.getElements();

assert.equal(elements.length, 3);
Expand All @@ -44,7 +44,7 @@ suite('Breadcrumb Model', function () {

test('only uri, outside workspace', function () {

let model = new EditorBreadcrumbsModel(URI.parse('foo:/outside/file.ts'), undefined, configService, workspaceService);
let model = new EditorBreadcrumbsModel(URI.parse('foo:/outside/file.ts'), undefined, configService, configService, workspaceService);
let elements = model.getElements();

assert.equal(elements.length, 2);
Expand Down

0 comments on commit 9d9a99d

Please sign in to comment.