From 1236ff9dc5702510a58461018d5f0801f8cd35f3 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 10 Apr 2017 08:20:39 +0200 Subject: [PATCH] Unable to change encoding for untitled files (fixes #24356) --- .../browser/parts/editor/editorStatus.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 49287c524fc..c678538d5c5 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -1078,14 +1078,15 @@ export class ChangeEncodingAction extends Action { return undefined; } - const guessEncoding = () => { - const resource = toResource(activeEditor.input); - return this.fileService.resolveContent(resource, { autoGuessEncoding: true, acceptTextOnly: true }) - .then(content => content.encoding, err => null); - }; - return TPromise.timeout(50 /* quick open is sensitive to being opened so soon after another */) - .then(guessEncoding) + .then(() => { + const resource = toResource(activeEditor.input, { filter: 'file', supportSideBySide: true }); + if (!resource) { + return TPromise.as(null); + } + + return this.fileService.resolveContent(resource, { autoGuessEncoding: true, acceptTextOnly: true }).then(content => content.encoding, err => null); + }) .then(guessedEncoding => { const configuration = this.configurationService.getConfiguration(); -- GitLab