Skip to content

Commit 6c369ea

Browse files
author
Benjamin Pasero
committed
1 parent 282af06 commit 6c369ea

5 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/vs/platform/editor/common/editor.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export interface IResourceInput extends IBaseResourceInput {
5555
* The encoding of the text input if known.
5656
*/
5757
encoding?: string;
58+
59+
/**
60+
* Hint to indicate that this input should be treated as a file
61+
* that opens in an editor capable of showing file content.
62+
*/
63+
isFile?: boolean;
5864
}
5965

6066
export interface IEditorOptions {

src/vs/workbench/electron-browser/workbench.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ export class Workbench extends Disposable implements IPartService {
834834
if (isNew) {
835835
input = { filePath: resource.fsPath, options: { pinned: true } } as IUntitledResourceInput;
836836
} else {
837-
input = { resource, options: { pinned: true } } as IResourceInput;
837+
input = { resource, options: { pinned: true }, isFile: true } as IResourceInput;
838838
}
839839

840840
if (!isNew && p.lineNumber) {

src/vs/workbench/parts/files/electron-browser/files.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class FileEditorInputFactory implements IEditorInputFactory {
154154
const resource = !!fileInput.resourceJSON ? URI.revive(fileInput.resourceJSON) : URI.parse(fileInput.resource);
155155
const encoding = fileInput.encoding;
156156

157-
return accessor.get(IEditorService).createInput({ resource, encoding }, { forceFileInput: true }) as FileEditorInput;
157+
return accessor.get(IEditorService).createInput({ resource, encoding, isFile: true }) as FileEditorInput;
158158
});
159159
}
160160
}

src/vs/workbench/services/editor/browser/editorService.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
454454

455455
//#region createInput()
456456

457-
createInput(input: IEditorInputWithOptions | IEditorInput | IResourceEditor, options?: { forceFileInput: boolean }): EditorInput {
457+
createInput(input: IEditorInputWithOptions | IEditorInput | IResourceEditor): EditorInput {
458458

459459
// Typed Editor Input Support (EditorInput)
460460
if (input instanceof EditorInput) {
@@ -470,8 +470,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
470470
// Side by Side Support
471471
const resourceSideBySideInput = <IResourceSideBySideInput>input;
472472
if (resourceSideBySideInput.masterResource && resourceSideBySideInput.detailResource) {
473-
const masterInput = this.createInput({ resource: resourceSideBySideInput.masterResource }, options);
474-
const detailInput = this.createInput({ resource: resourceSideBySideInput.detailResource }, options);
473+
const masterInput = this.createInput({ resource: resourceSideBySideInput.masterResource });
474+
const detailInput = this.createInput({ resource: resourceSideBySideInput.detailResource });
475475

476476
return new SideBySideEditorInput(
477477
resourceSideBySideInput.label || masterInput.getName(),
@@ -484,8 +484,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
484484
// Diff Editor Support
485485
const resourceDiffInput = <IResourceDiffInput>input;
486486
if (resourceDiffInput.leftResource && resourceDiffInput.rightResource) {
487-
const leftInput = this.createInput({ resource: resourceDiffInput.leftResource }, options);
488-
const rightInput = this.createInput({ resource: resourceDiffInput.rightResource }, options);
487+
const leftInput = this.createInput({ resource: resourceDiffInput.leftResource });
488+
const rightInput = this.createInput({ resource: resourceDiffInput.rightResource });
489489
const label = resourceDiffInput.label || localize('compareLabels', "{0} ↔ {1}", this.toDiffLabel(leftInput), this.toDiffLabel(rightInput));
490490

491491
return new DiffEditorInput(label, resourceDiffInput.description, leftInput, rightInput);
@@ -510,13 +510,13 @@ export class EditorService extends Disposable implements EditorServiceImpl {
510510
label = basename(resourceInput.resource.fsPath); // derive the label from the path (but not for data URIs)
511511
}
512512

513-
return this.createOrGet(resourceInput.resource, this.instantiationService, label, resourceInput.description, resourceInput.encoding, options && options.forceFileInput) as EditorInput;
513+
return this.createOrGet(resourceInput.resource, this.instantiationService, label, resourceInput.description, resourceInput.encoding, resourceInput.isFile) as EditorInput;
514514
}
515515

516516
return null;
517517
}
518518

519-
private createOrGet(resource: URI, instantiationService: IInstantiationService, label: string, description: string, encoding?: string, forceFileInput?: boolean): ICachedEditorInput {
519+
private createOrGet(resource: URI, instantiationService: IInstantiationService, label: string, description: string, encoding?: string, isFile?: boolean): ICachedEditorInput {
520520
if (EditorService.CACHE.has(resource)) {
521521
const input = EditorService.CACHE.get(resource);
522522
if (input instanceof ResourceEditorInput) {
@@ -532,7 +532,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
532532
let input: ICachedEditorInput;
533533

534534
// File
535-
if (this.fileService.canHandleResource(resource) || forceFileInput /* fix for https://github.com/Microsoft/vscode/issues/48275 */) {
535+
if (isFile /* fix for https://github.com/Microsoft/vscode/issues/48275 */ || this.fileService.canHandleResource(resource)) {
536536
input = this.fileInputFactory.createFileInput(resource, encoding, instantiationService);
537537
}
538538

src/vs/workbench/services/editor/common/editorService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,5 @@ export interface IEditorService {
166166
/**
167167
* Converts a lightweight input to a workbench editor input.
168168
*/
169-
createInput(input: IResourceEditor, options?: { forceFileInput: boolean }): IEditorInput;
169+
createInput(input: IResourceEditor): IEditorInput;
170170
}

0 commit comments

Comments
 (0)