Skip to content

Commit 9d56906

Browse files
committed
editors - move decorateFileEditorLabel to common place
1 parent d7b9d87 commit 9d56906

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

src/vs/workbench/common/editor.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,22 @@ export interface IFileEditorInput extends IEditorInput, IEncodingSupport, IModeS
748748
isResolved(): boolean;
749749
}
750750

751+
export function decorateFileEditorLabel(label: string, state: { orphaned: boolean, readonly: boolean }): string {
752+
if (state.orphaned && state.readonly) {
753+
return localize('orphanedReadonlyFile', "{0} (deleted, read-only)", label);
754+
}
755+
756+
if (state.orphaned) {
757+
return localize('orphanedFile', "{0} (deleted)", label);
758+
}
759+
760+
if (state.readonly) {
761+
return localize('readonlyFile', "{0} (read-only)", label);
762+
}
763+
764+
return label;
765+
}
766+
751767
/**
752768
* Side by side editor inputs that have a primary and secondary side.
753769
*/

src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
1616
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1717
import { ILabelService } from 'vs/platform/label/common/label';
1818
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
19-
import { GroupIdentifier, IEditorInput, IRevertOptions, ISaveOptions, Verbosity } from 'vs/workbench/common/editor';
19+
import { decorateFileEditorLabel, GroupIdentifier, IEditorInput, IRevertOptions, ISaveOptions, Verbosity } from 'vs/workbench/common/editor';
2020
import { defaultCustomEditor } from 'vs/workbench/contrib/customEditor/common/contributedCustomEditors';
2121
import { ICustomEditorModel, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
22-
import { decorateFileEditorLabel } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
2322
import { IWebviewService, WebviewOverlay } from 'vs/workbench/contrib/webview/browser/webview';
2423
import { IWebviewWorkbenchService, LazilyResolvedWebviewEditorInput } from 'vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService';
2524
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';

src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { localize } from 'vs/nls';
76
import { URI } from 'vs/base/common/uri';
8-
import { IFileEditorInput, Verbosity, GroupIdentifier, IMoveResult, isTextEditorPane } from 'vs/workbench/common/editor';
7+
import { IFileEditorInput, Verbosity, GroupIdentifier, IMoveResult, isTextEditorPane, decorateFileEditorLabel } from 'vs/workbench/common/editor';
98
import { AbstractTextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput';
109
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
1110
import { FileOperationError, FileOperationResult, IFileService } from 'vs/platform/files/common/files';
@@ -188,6 +187,7 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
188187
private decorateLabel(label: string): string {
189188
const orphaned = this.model?.hasState(TextFileEditorModelState.ORPHAN);
190189
const readonly = this.isReadonly();
190+
191191
return decorateFileEditorLabel(label, { orphaned: !!orphaned, readonly });
192192
}
193193

@@ -394,19 +394,3 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
394394
this.cachedTextFileModelReference = undefined;
395395
}
396396
}
397-
398-
export function decorateFileEditorLabel(label: string, state: { orphaned: boolean, readonly: boolean }): string {
399-
if (state.orphaned && state.readonly) {
400-
return localize('orphanedReadonlyFile', "{0} (deleted, read-only)", label);
401-
}
402-
403-
if (state.orphaned) {
404-
return localize('orphanedFile', "{0} (deleted)", label);
405-
}
406-
407-
if (state.readonly) {
408-
return localize('readonlyFile', "{0} (read-only)", label);
409-
}
410-
411-
return label;
412-
}

0 commit comments

Comments
 (0)