@@ -21,6 +21,8 @@ import { DocumentSymbolProviderRegistry } from 'vs/editor/common/modes';
21
21
import { OutlineElement , OutlineGroup , OutlineModel } from 'vs/editor/contrib/documentSymbols/outlineModel' ;
22
22
import { IWorkspaceContextService , IWorkspaceFolder , WorkbenchState } from 'vs/platform/workspace/common/workspace' ;
23
23
import { Schemas } from 'vs/base/common/network' ;
24
+ import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
25
+ import { BreadcrumbsConfig } from 'vs/workbench/browser/parts/editor/breadcrumbs' ;
24
26
25
27
export class FileElement {
26
28
constructor (
@@ -38,6 +40,9 @@ export class EditorBreadcrumbsModel {
38
40
private readonly _disposables : IDisposable [ ] = [ ] ;
39
41
private readonly _fileInfo : FileInfo ;
40
42
43
+ private readonly _cfgFilePath : BreadcrumbsConfig < 'on' | 'off' | 'last' > ;
44
+ private readonly _cfgSymbolPath : BreadcrumbsConfig < 'on' | 'off' | 'last' > ;
45
+
41
46
private _outlineElements : ( OutlineGroup | OutlineElement ) [ ] = [ ] ;
42
47
private _outlineDisposables : IDisposable [ ] = [ ] ;
43
48
@@ -48,13 +53,23 @@ export class EditorBreadcrumbsModel {
48
53
private readonly _uri : URI ,
49
54
private readonly _editor : ICodeEditor | undefined ,
50
55
@IWorkspaceContextService workspaceService : IWorkspaceContextService ,
56
+ @IConfigurationService configurationService : IConfigurationService ,
51
57
) {
58
+
59
+ this . _cfgFilePath = BreadcrumbsConfig . FilePath . bindTo ( configurationService ) ;
60
+ this . _cfgSymbolPath = BreadcrumbsConfig . SymbolPath . bindTo ( configurationService ) ;
61
+
62
+ this . _disposables . push ( this . _cfgFilePath . onDidChange ( _ => this . _onDidUpdate . fire ( this ) ) ) ;
63
+ this . _disposables . push ( this . _cfgSymbolPath . onDidChange ( _ => this . _onDidUpdate . fire ( this ) ) ) ;
64
+
52
65
this . _fileInfo = EditorBreadcrumbsModel . _initFilePathInfo ( this . _uri , workspaceService ) ;
53
66
this . _bindToEditor ( ) ;
54
67
this . _onDidUpdate . fire ( this ) ;
55
68
}
56
69
57
70
dispose ( ) : void {
71
+ this . _cfgFilePath . dispose ( ) ;
72
+ this . _cfgSymbolPath . dispose ( ) ;
58
73
dispose ( this . _disposables ) ;
59
74
}
60
75
@@ -63,7 +78,23 @@ export class EditorBreadcrumbsModel {
63
78
}
64
79
65
80
getElements ( ) : ReadonlyArray < BreadcrumbElement > {
66
- return [ ] . concat ( this . _fileInfo . path , this . _outlineElements ) ;
81
+ let result : BreadcrumbElement [ ] = [ ] ;
82
+
83
+ // file path elements
84
+ if ( this . _cfgFilePath . value === 'on' ) {
85
+ result = result . concat ( this . _fileInfo . path ) ;
86
+ } else if ( this . _cfgFilePath . value === 'last' && this . _fileInfo . path . length > 0 ) {
87
+ result = result . concat ( this . _fileInfo . path . slice ( - 1 ) ) ;
88
+ }
89
+
90
+ // symbol path elements
91
+ if ( this . _cfgSymbolPath . value === 'on' ) {
92
+ result = result . concat ( this . _outlineElements ) ;
93
+ } else if ( this . _cfgSymbolPath . value === 'last' && this . _outlineElements . length > 0 ) {
94
+ result = result . concat ( this . _outlineElements . slice ( - 1 ) ) ;
95
+ }
96
+
97
+ return result ;
67
98
}
68
99
69
100
private static _initFilePathInfo ( uri : URI , workspaceService : IWorkspaceContextService ) : FileInfo {
0 commit comments