diff --git a/src/constants.ts b/src/constants.ts index fa6e3f3..5aae205 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -11,41 +11,19 @@ export const ImageMimetypes: Record = { '.bmp': 'image/bmp', }; -export const enum BuiltInCommands { - CloseActiveEditor = 'workbench.action.closeActiveEditor', - CloseAllEditors = 'workbench.action.closeAllEditors', - CursorMove = 'cursorMove', - Diff = 'vscode.diff', - EditorScroll = 'editorScroll', - ExecuteDocumentSymbolProvider = 'vscode.executeDocumentSymbolProvider', - ExecuteCodeLensProvider = 'vscode.executeCodeLensProvider', - FocusFilesExplorer = 'workbench.files.action.focusFilesExplorer', - InstallExtension = 'workbench.extensions.installExtension', - Open = 'vscode.open', - OpenFolder = 'vscode.openFolder', - OpenInTerminal = 'openInTerminal', - OpenWith = 'vscode.openWith', - NextEditor = 'workbench.action.nextEditor', - PreviewHtml = 'vscode.previewHtml', - RevealLine = 'revealLine', - SetContext = 'setContext', - ShowExplorerActivity = 'workbench.view.explorer', - ShowReferences = 'editor.action.showReferences', -} - -export const enum BuiltInGitCommands { - Publish = 'git.publish', - Pull = 'git.pull', - PullRebase = 'git.pullRebase', - Push = 'git.push', - PushForce = 'git.pushForce', - UndoCommit = 'git.undoCommit', -} - -export const enum BuiltInGitConfiguration { - AutoRepositoryDetection = 'git.autoRepositoryDetection', - FetchOnPull = 'git.fetchOnPull', - UseForcePushWithLease = 'git.useForcePushWithLease', +export const enum CharCode { + /** + * The `/` character. + */ + Slash = 47, + /** + * The `\` character. + */ + Backslash = 92, + A = 65, + Z = 90, + a = 97, + z = 122, } export const enum Colors { @@ -66,19 +44,6 @@ export const enum Colors { UnpulledChangesIconColor = 'gitlens.unpulledChangesIconColor', } -export const enum Schemes { - DebugConsole = 'debug', - File = 'file', - Git = 'git', - GitHub = 'github', - GitLens = 'gitlens', - Output = 'output', - PRs = 'pr', - Vsls = 'vsls', - VslsScc = 'vsls-scc', - Virtual = 'vscode-vfs', -} - export const enum GlyphChars { AngleBracketLeftHeavy = '\u2770', AngleBracketRightHeavy = '\u2771', @@ -125,3 +90,53 @@ export const enum GlyphChars { Warning = '\u26a0', ZeroWidthSpace = '\u200b', } + +export const enum Schemes { + DebugConsole = 'debug', + File = 'file', + Git = 'git', + GitHub = 'github', + GitLens = 'gitlens', + Output = 'output', + PRs = 'pr', + Vsls = 'vsls', + VslsScc = 'vsls-scc', + Virtual = 'vscode-vfs', +} + +export const enum BuiltInCommands { + CloseActiveEditor = 'workbench.action.closeActiveEditor', + CloseAllEditors = 'workbench.action.closeAllEditors', + CursorMove = 'cursorMove', + Diff = 'vscode.diff', + EditorScroll = 'editorScroll', + ExecuteDocumentSymbolProvider = 'vscode.executeDocumentSymbolProvider', + ExecuteCodeLensProvider = 'vscode.executeCodeLensProvider', + FocusFilesExplorer = 'workbench.files.action.focusFilesExplorer', + InstallExtension = 'workbench.extensions.installExtension', + Open = 'vscode.open', + OpenFolder = 'vscode.openFolder', + OpenInTerminal = 'openInTerminal', + OpenWith = 'vscode.openWith', + NextEditor = 'workbench.action.nextEditor', + PreviewHtml = 'vscode.previewHtml', + RevealLine = 'revealLine', + SetContext = 'setContext', + ShowExplorerActivity = 'workbench.view.explorer', + ShowReferences = 'editor.action.showReferences', +} + +export const enum BuiltInGitCommands { + Publish = 'git.publish', + Pull = 'git.pull', + PullRebase = 'git.pullRebase', + Push = 'git.push', + PushForce = 'git.pushForce', + UndoCommit = 'git.undoCommit', +} + +export const enum BuiltInGitConfiguration { + AutoRepositoryDetection = 'git.autoRepositoryDetection', + FetchOnPull = 'git.fetchOnPull', + UseForcePushWithLease = 'git.useForcePushWithLease', +} diff --git a/src/premium/github/githubGitProvider.ts b/src/premium/github/githubGitProvider.ts index 0f5bbbd..eb4fe28 100644 --- a/src/premium/github/githubGitProvider.ts +++ b/src/premium/github/githubGitProvider.ts @@ -15,7 +15,7 @@ import { } from 'vscode'; import { encodeUtf8Hex } from '@env/hex'; import { configuration } from '../../configuration'; -import { Schemes } from '../../constants'; +import { CharCode, Schemes } from '../../constants'; import type { Container } from '../../container'; import { AuthenticationError, @@ -82,7 +82,6 @@ import { gate } from '../../system/decorators/gate'; import { debug, log } from '../../system/decorators/log'; import { filterMap, some } from '../../system/iterable'; import { isAbsolute, isFolderGlob, maybeUri, normalizePath, relative } from '../../system/path'; -import { CharCode } from '../../system/string'; import { CachedBlame, CachedLog, GitDocumentState } from '../../trackers/gitDocumentTracker'; import { TrackedDocument } from '../../trackers/trackedDocument'; import { fromCommitFileStatus, GitHubApi } from '../github/github'; diff --git a/src/system/searchTree.ts b/src/system/searchTree.ts index 347a15a..a4bc2a3 100644 --- a/src/system/searchTree.ts +++ b/src/system/searchTree.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/strict-boolean-expressions */ +import { CharCode } from '../constants'; import { count, map, some } from './iterable'; -import { CharCode, compareSubstring, compareSubstringIgnoreCase } from './string'; +import { compareSubstring, compareSubstringIgnoreCase } from './string'; const FIN = { done: true, value: undefined }; diff --git a/src/system/string.ts b/src/system/string.ts index 3c8dbf0..e4fe295 100644 --- a/src/system/string.ts +++ b/src/system/string.ts @@ -1,26 +1,10 @@ import ansiRegex from 'ansi-regex'; import { md5 as _md5 } from '@env/crypto'; import { hrtime } from '@env/hrtime'; +import { CharCode } from '../constants'; export { fromBase64, base64 } from '@env/base64'; -const emptyStr = ''; - -export const enum CharCode { - /** - * The `/` character. - */ - Slash = 47, - /** - * The `\` character. - */ - Backslash = 92, - A = 65, - Z = 90, - a = 97, - z = 122, -} - const compareCollator = new Intl.Collator(undefined, { sensitivity: 'accent' }); export function compareIgnoreCase(a: string, b: string): 0 | -1 | 1 { const result = compareCollator.compare(a, b); @@ -217,7 +201,7 @@ const interpolationMap = new Map(); export function interpolate(template: string, context: object | undefined): string { if (template == null || template.length === 0) return template; - if (context == null) return template.replace(tokenSanitizeRegex, emptyStr); + if (context == null) return template.replace(tokenSanitizeRegex, ''); let fn = interpolationMap.get(template); if (fn == null) { @@ -240,7 +224,7 @@ const interpolationAsyncMap = new Map(); export async function interpolateAsync(template: string, context: object | undefined): Promise { if (template == null || template.length === 0) return template; - if (context == null) return template.replace(tokenSanitizeRegex, emptyStr); + if (context == null) return template.replace(tokenSanitizeRegex, ''); let fn = interpolationAsyncMap.get(template); if (fn == null) { @@ -269,7 +253,7 @@ export function md5(s: string, encoding: 'base64' | 'hex' = 'base64'): string { export function pad(s: string, before: number = 0, after: number = 0, padding: string = '\u00a0') { if (before === 0 && after === 0) return s; - return `${before === 0 ? emptyStr : padding.repeat(before)}${s}${after === 0 ? emptyStr : padding.repeat(after)}`; + return `${before === 0 ? '' : padding.repeat(before)}${s}${after === 0 ? '' : padding.repeat(after)}`; } export function padLeft(s: string, padTo: number, padding: string = '\u00a0', width?: number) { @@ -322,7 +306,7 @@ export function pluralize( zero?: string; }, ) { - if (options == null) return `${count} ${s}${count === 1 ? emptyStr : 's'}`; + if (options == null) return `${count} ${s}${count === 1 ? '' : 's'}`; const suffix = count === 1 ? s : options.plural ?? `${s}s`; if (options.only) return suffix; @@ -419,7 +403,7 @@ export function getWidth(s: string): number { if (cachedAnsiRegex == null) { cachedAnsiRegex = ansiRegex(); } - s = s.replace(cachedAnsiRegex, emptyStr); + s = s.replace(cachedAnsiRegex, ''); let count = 0; let emoji = 0;