diff --git a/src/vs/workbench/services/textfile/common/textFileService.ts b/src/vs/workbench/services/textfile/common/textFileService.ts index 74e85b93b46de1e141765bd078f3c68279eade52..45efd5afbea9501e7879fc539a8d21b0634f4c90 100644 --- a/src/vs/workbench/services/textfile/common/textFileService.ts +++ b/src/vs/workbench/services/textfile/common/textFileService.ts @@ -39,6 +39,7 @@ import { coalesce } from 'vs/base/common/arrays'; import { trim } from 'vs/base/common/strings'; import { VSBuffer } from 'vs/base/common/buffer'; import { ITextSnapshot } from 'vs/editor/common/model'; +import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; /** * The workbench file service implementation implements the raw file service spec and adds additional methods on top. @@ -85,7 +86,8 @@ export abstract class TextFileService extends Disposable implements ITextFileSer @IContextKeyService contextKeyService: IContextKeyService, @IDialogService private readonly dialogService: IDialogService, @IFileDialogService private readonly fileDialogService: IFileDialogService, - @IEditorService private readonly editorService: IEditorService + @IEditorService private readonly editorService: IEditorService, + @ITextResourceConfigurationService protected readonly textResourceConfigurationService: ITextResourceConfigurationService ) { super(); diff --git a/src/vs/workbench/services/textfile/node/textFileService.ts b/src/vs/workbench/services/textfile/node/textFileService.ts index 5116b02c7c5fdf3f42264adb3c33f185576dc372..de436eff4c068c13b73498e0e33e01d4d60d04a1 100644 --- a/src/vs/workbench/services/textfile/node/textFileService.ts +++ b/src/vs/workbench/services/textfile/node/textFileService.ts @@ -70,7 +70,7 @@ export class NodeTextFileService extends TextFileService { // read through encoding library const decoder = await toDecodeStream(this.streamToNodeReadable(bufferStream.value), { - guessEncoding: options && options.autoGuessEncoding, + guessEncoding: (options && options.autoGuessEncoding) || this.textResourceConfigurationService.getValue(resource, 'files.autoGuessEncoding'), overwriteEncoding: detected => this.encoding.getReadEncoding(resource, options, { encoding: detected, seemsBinary: false }) });