mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 10:38:31 -05:00
Merge from vscode 2cd495805cf99b31b6926f08ff4348124b2cf73d
This commit is contained in:
committed by
AzureDataStudio
parent
a8a7559229
commit
1388493cc1
@@ -3,18 +3,22 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { AbstractTextFileService } from 'vs/workbench/services/textfile/browser/textFileService';
|
||||
import { ITextFileService, IResourceEncodings, IResourceEncoding, TextFileEditorModelState } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { AbstractTextFileService, EncodingOracle } from 'vs/workbench/services/textfile/browser/textFileService';
|
||||
import { ITextFileService, IResourceEncoding, TextFileEditorModelState } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
export class BrowserTextFileService extends AbstractTextFileService {
|
||||
|
||||
readonly encoding: IResourceEncodings = {
|
||||
async getPreferredWriteEncoding(): Promise<IResourceEncoding> {
|
||||
return { encoding: 'utf8', hasBOM: false };
|
||||
private _browserEncoding: EncodingOracle | undefined;
|
||||
|
||||
get encoding(): EncodingOracle {
|
||||
if (!this._browserEncoding) {
|
||||
this._browserEncoding = this._register(this.instantiationService.createInstance(BrowserEncodingOracle));
|
||||
}
|
||||
};
|
||||
|
||||
return this._browserEncoding;
|
||||
}
|
||||
|
||||
protected registerListeners(): void {
|
||||
super.registerListeners();
|
||||
@@ -34,4 +38,18 @@ export class BrowserTextFileService extends AbstractTextFileService {
|
||||
}
|
||||
}
|
||||
|
||||
class BrowserEncodingOracle extends EncodingOracle {
|
||||
async getPreferredWriteEncoding(): Promise<IResourceEncoding> {
|
||||
return { encoding: 'utf8', hasBOM: false };
|
||||
}
|
||||
|
||||
async getWriteEncoding(): Promise<{ encoding: string, addBOM: boolean }> {
|
||||
return { encoding: 'utf8', addBOM: false };
|
||||
}
|
||||
|
||||
async getReadEncoding(): Promise<string> {
|
||||
return 'utf8';
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(ITextFileService, BrowserTextFileService);
|
||||
|
||||
Reference in New Issue
Block a user