Browse Source

Avoids importing `iconv-lite` in web bundle

main
Eric Amodio 1 year ago
parent
commit
575227c264
2 changed files with 8 additions and 9 deletions
  1. +8
    -3
      src/env/node/git/localGitProvider.ts
  2. +0
    -6
      src/git/gitProviderService.ts

+ 8
- 3
src/env/node/git/localGitProvider.ts View File

@ -2,6 +2,7 @@ import { readdir, realpath } from 'fs';
import { homedir, hostname, userInfo } from 'os';
import { resolve as resolvePath } from 'path';
import { env as process_env } from 'process';
import { encodingExists } from 'iconv-lite';
import type { CancellationToken, Event, TextDocument, WorkspaceFolder } from 'vscode';
import { Disposable, env, EventEmitter, extensions, FileType, Range, Uri, window, workspace } from 'vscode';
import { fetch, getProxyAgent } from '@env/fetch';
@ -44,7 +45,6 @@ import type {
ScmRepository,
} from '../../../git/gitProvider';
import { GitProviderId, RepositoryVisibility } from '../../../git/gitProvider';
import { GitProviderService } from '../../../git/gitProviderService';
import { encodeGitLensRevisionUriAuthority, GitUri } from '../../../git/gitUri';
import type { GitBlame, GitBlameAuthor, GitBlameLine, GitBlameLines } from '../../../git/models/blame';
import type { BranchSortOptions } from '../../../git/models/branch';
@ -2336,7 +2336,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
uri.fsPath,
ref1,
ref2,
{ encoding: GitProviderService.getEncoding(uri) },
{ encoding: getEncoding(uri) },
doc,
key,
scope,
@ -2424,7 +2424,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
uri.fsPath,
ref,
contents,
{ encoding: GitProviderService.getEncoding(uri) },
{ encoding: getEncoding(uri) },
doc,
key,
scope,
@ -4838,3 +4838,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
);
}
}
function getEncoding(uri: Uri): string {
const encoding = configuration.getAny<string>('files.encoding', uri);
return encoding != null && encodingExists(encoding) ? encoding : 'utf8';
}

+ 0
- 6
src/git/gitProviderService.ts View File

@ -1,4 +1,3 @@
import { encodingExists } from 'iconv-lite';
import type {
CancellationToken,
ConfigurationChangeEvent,
@ -2515,9 +2514,4 @@ export class GitProviderService implements Disposable {
const { provider, path } = this.getProvider(repoPath);
return provider.getOrOpenScmRepository(path);
}
static getEncoding(uri: Uri): string {
const encoding = configuration.getAny<string>('files.encoding', uri);
return encoding != null && encodingExists(encoding) ? encoding : 'utf8';
}
}

Loading…
Cancel
Save