@@ -26,7 +26,12 @@ export interface RegisterFormatterEvent {
2626
2727export interface ILabelService {
2828 _serviceBrand : any ;
29- getUriLabel ( resource : URI , options ?: { relative ?: boolean , forceNoTildify ?: boolean } ) : string ;
29+ /**
30+ * Gets the human readable label for a uri.
31+ * If relative is passed returns a label relative to the workspace root that the uri belongs to.
32+ * If noPrefix is passed does not tildify the label and also does not prepand the root name for relative labels in a multi root scenario.
33+ */
34+ getUriLabel ( resource : URI , options ?: { relative ?: boolean , noPrefix ?: boolean } ) : string ;
3035 getWorkspaceLabel ( workspace : ( IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | IWorkspace ) , options ?: { verbose : boolean } ) : string ;
3136 registerFormatter ( schema : string , formatter : LabelRules ) : IDisposable ;
3237 onDidRegisterFormatter : Event < RegisterFormatterEvent > ;
@@ -67,7 +72,7 @@ export class LabelService implements ILabelService {
6772 return this . _onDidRegisterFormatter . event ;
6873 }
6974
70- getUriLabel ( resource : URI , options : { relative ?: boolean , forceNoTildify ?: boolean } = { } ) : string {
75+ getUriLabel ( resource : URI , options : { relative ?: boolean , noPrefix ?: boolean } = { } ) : string {
7176 if ( ! resource ) {
7277 return undefined ;
7378 }
@@ -83,12 +88,12 @@ export class LabelService implements ILabelService {
8388 if ( isEqual ( baseResource . uri , resource , ! isLinux ) ) {
8489 relativeLabel = '' ; // no label if resources are identical
8590 } else {
86- const baseResourceLabel = this . formatUri ( baseResource . uri , formatter , options . forceNoTildify ) ;
87- relativeLabel = ltrim ( this . formatUri ( resource , formatter , options . forceNoTildify ) . substring ( baseResourceLabel . length ) , formatter . uri . separator ) ;
91+ const baseResourceLabel = this . formatUri ( baseResource . uri , formatter , options . noPrefix ) ;
92+ relativeLabel = ltrim ( this . formatUri ( resource , formatter , options . noPrefix ) . substring ( baseResourceLabel . length ) , formatter . uri . separator ) ;
8893 }
8994
9095 const hasMultipleRoots = this . contextService . getWorkspace ( ) . folders . length > 1 ;
91- if ( hasMultipleRoots ) {
96+ if ( hasMultipleRoots && ! options . noPrefix ) {
9297 const rootName = ( baseResource && baseResource . name ) ? baseResource . name : basenameOrAuthority ( baseResource . uri ) ;
9398 relativeLabel = relativeLabel ? ( rootName + ' • ' + relativeLabel ) : rootName ; // always show root basename if there are multiple
9499 }
@@ -97,7 +102,7 @@ export class LabelService implements ILabelService {
97102 }
98103 }
99104
100- return this . formatUri ( resource , formatter , options . forceNoTildify ) ;
105+ return this . formatUri ( resource , formatter , options . noPrefix ) ;
101106 }
102107
103108 getWorkspaceLabel ( workspace : ( IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | IWorkspace ) , options ?: { verbose : boolean } ) : string {
0 commit comments