mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
only detect git encoding if files.autoGuessEncoding is enabled
fixes #46826
This commit is contained in:
parent
8934ecc3f4
commit
42c882151f
|
@ -660,9 +660,13 @@ export class Repository {
|
|||
return result.stdout;
|
||||
}
|
||||
|
||||
async bufferString(object: string, encoding: string = 'utf8'): Promise<string> {
|
||||
async bufferString(object: string, encoding: string = 'utf8', autoGuessEncoding = false): Promise<string> {
|
||||
const stdout = await this.buffer(object);
|
||||
encoding = detectEncoding(stdout) || encoding;
|
||||
|
||||
if (autoGuessEncoding) {
|
||||
encoding = detectEncoding(stdout) || encoding;
|
||||
}
|
||||
|
||||
encoding = iconv.encodingExists(encoding) ? encoding : 'utf8';
|
||||
|
||||
return iconv.decode(stdout, encoding);
|
||||
|
|
|
@ -815,7 +815,9 @@ export class Repository implements Disposable {
|
|||
const relativePath = path.relative(this.repository.root, filePath).replace(/\\/g, '/');
|
||||
const configFiles = workspace.getConfiguration('files', Uri.file(filePath));
|
||||
const defaultEncoding = configFiles.get<string>('encoding');
|
||||
return this.repository.bufferString(`${ref}:${relativePath}`, defaultEncoding);
|
||||
const autoGuessEncoding = configFiles.get<boolean>('autoGuessEncoding');
|
||||
|
||||
return this.repository.bufferString(`${ref}:${relativePath}`, defaultEncoding, autoGuessEncoding);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue