@@ -7,10 +7,10 @@ import { localize } from 'vs/nls';
7
7
import { assertIsDefined } from 'vs/base/common/types' ;
8
8
import { IPathService } from 'vs/workbench/services/path/common/pathService' ;
9
9
import { toAction } from 'vs/base/common/actions' ;
10
- import { VIEWLET_ID , TEXT_FILE_EDITOR_ID } from 'vs/workbench/contrib/files/common/files' ;
10
+ import { VIEWLET_ID , TEXT_FILE_EDITOR_ID , BINARY_TEXT_FILE_MODE } from 'vs/workbench/contrib/files/common/files' ;
11
11
import { ITextFileService , TextFileOperationError , TextFileOperationResult } from 'vs/workbench/services/textfile/common/textfiles' ;
12
12
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor' ;
13
- import { IEditorOpenContext , EditorInputCapabilities , isTextEditorViewState } from 'vs/workbench/common/editor' ;
13
+ import { IEditorOpenContext , EditorInputCapabilities , isTextEditorViewState , DEFAULT_EDITOR_ASSOCIATION } from 'vs/workbench/common/editor' ;
14
14
import { EditorInput } from 'vs/workbench/common/editor/editorInput' ;
15
15
import { applyTextEditorOptions } from 'vs/workbench/common/editor/editorOptions' ;
16
16
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel' ;
@@ -213,7 +213,7 @@ export class TextFileEditor extends BaseTextEditor<ICodeEditorViewState> {
213
213
private openAsBinary ( input : FileEditorInput , options : ITextEditorOptions | undefined ) : void {
214
214
const defaultBinaryEditor = this . configurationService . getValue < string | undefined > ( 'workbench.editor.defaultBinaryEditor' ) ;
215
215
const groupToOpen = this . group ?? this . editorGroupService . activeGroup ;
216
- const editorOptions = {
216
+ let editorOptions = {
217
217
...options ,
218
218
// Make sure to not steal away the currently active group
219
219
// because we are triggering another openEditor() call
@@ -223,19 +223,25 @@ export class TextFileEditor extends BaseTextEditor<ICodeEditorViewState> {
223
223
} ;
224
224
225
225
// If we the user setting specifies a default binary editor we use that
226
- if ( defaultBinaryEditor && defaultBinaryEditor !== '' ) {
226
+ if ( defaultBinaryEditor && defaultBinaryEditor !== '' && defaultBinaryEditor !== DEFAULT_EDITOR_ASSOCIATION . id ) {
227
227
this . editorService . replaceEditors ( [ {
228
228
editor : input ,
229
229
replacement : { resource : input . resource , options : { ...editorOptions , override : defaultBinaryEditor } }
230
230
} ] , groupToOpen ) ;
231
- }
232
-
233
- // Otherwise we mark file input for forced binary opening and reopen the file
234
- else {
231
+ // Replace is completed, don't do any further text input options as it's no longer text.
232
+ return ;
233
+ } else if ( defaultBinaryEditor === DEFAULT_EDITOR_ASSOCIATION . id ) {
234
+ input . setForceOpenAsText ( ) ;
235
+ // Distinguish between plain text and plain text binary
236
+ input . setPreferredLanguageId ( BINARY_TEXT_FILE_MODE ) ;
237
+ // Same pane and same input, must force reload to clear cached state
238
+ editorOptions = { ...editorOptions , forceReload : true } ;
239
+ } else {
235
240
input . setForceOpenAsBinary ( ) ;
236
-
237
- groupToOpen . openEditor ( input , editorOptions ) ;
238
241
}
242
+
243
+ // Resolver wasn't needed proceed to oepn the editor as normal
244
+ groupToOpen . openEditor ( input , editorOptions ) ;
239
245
}
240
246
241
247
private async openAsFolder ( input : FileEditorInput ) : Promise < void > {
0 commit comments