Procházet zdrojové kódy

Changes `.splice(0, 0,` calls to `.unshift(`

main
Eric Amodio před 1 rokem
rodič
revize
b7d948c875
12 změnil soubory, kde provedl 90 přidání a 116 odebrání
  1. +2
    -6
      src/commands/quickCommand.steps.ts
  2. +72
    -82
      src/container.ts
  3. +4
    -8
      src/env/node/git/git.ts
  4. +1
    -1
      src/quickpicks/modePicker.ts
  5. +3
    -3
      src/quickpicks/referencePicker.ts
  6. +1
    -3
      src/views/nodes/branchTrackingStatusNode.ts
  7. +2
    -4
      src/views/nodes/commitNode.ts
  8. +1
    -3
      src/views/nodes/lineHistoryNode.ts
  9. +1
    -1
      src/views/nodes/rebaseStatusNode.ts
  10. +1
    -3
      src/views/nodes/statusFilesNode.ts
  11. +1
    -1
      src/views/nodes/worktreeNode.ts
  12. +1
    -1
      src/views/searchAndCompareView.ts

+ 2
- 6
src/commands/quickCommand.steps.ts Zobrazit soubor

@ -1989,9 +1989,7 @@ async function getShowCommitOrStashStepItems<
}),
);
items.splice(
0,
0,
items.unshift(
new CommitFilesQuickPickItem(state.reference, {
unpublished: unpublished,
hint: 'Click to see all changed files',
@ -2241,9 +2239,7 @@ async function getShowCommitOrStashFileStepItems<
}),
);
items.splice(
0,
0,
items.unshift(
new CommitFilesQuickPickItem(state.reference, { file: file, hint: 'Click to see all changed files' }),
);
return items as CommandQuickPickItem[];

+ 72
- 82
src/container.ts Zobrazit soubor

@ -171,94 +171,86 @@ export class Container {
this._version = version;
this.ensureModeApplied();
context.subscriptions.splice(0, 0, (this._storage = storage));
context.subscriptions.splice(0, 0, (this._telemetry = new TelemetryService(this)));
context.subscriptions.splice(0, 0, (this._usage = new UsageTracker(this, storage)));
context.subscriptions.unshift((this._storage = storage));
context.subscriptions.unshift((this._telemetry = new TelemetryService(this)));
context.subscriptions.unshift((this._usage = new UsageTracker(this, storage)));
context.subscriptions.splice(0, 0, configuration.onWillChange(this.onConfigurationChanging, this));
context.subscriptions.unshift(configuration.onWillChange(this.onConfigurationChanging, this));
this._richRemoteProviders = new RichRemoteProviderService(this);
const server = new ServerConnection(this);
context.subscriptions.splice(0, 0, server);
context.subscriptions.splice(
0,
0,
context.subscriptions.unshift(server);
context.subscriptions.unshift(
(this._subscriptionAuthentication = new SubscriptionAuthenticationProvider(this, server)),
);
context.subscriptions.splice(0, 0, (this._subscription = new SubscriptionService(this, previousVersion)));
context.subscriptions.unshift((this._subscription = new SubscriptionService(this, previousVersion)));
context.subscriptions.splice(0, 0, (this._git = new GitProviderService(this)));
context.subscriptions.splice(0, 0, new GitFileSystemProvider(this));
context.subscriptions.unshift((this._git = new GitProviderService(this)));
context.subscriptions.unshift(new GitFileSystemProvider(this));
context.subscriptions.splice(0, 0, (this._uri = new UriService(this)));
context.subscriptions.unshift((this._uri = new UriService(this)));
context.subscriptions.splice(0, 0, (this._deepLinks = new DeepLinkService(this)));
context.subscriptions.unshift((this._deepLinks = new DeepLinkService(this)));
context.subscriptions.splice(0, 0, (this._actionRunners = new ActionRunners(this)));
context.subscriptions.splice(0, 0, (this._tracker = new GitDocumentTracker(this)));
context.subscriptions.splice(0, 0, (this._lineTracker = new GitLineTracker(this)));
context.subscriptions.splice(0, 0, (this._keyboard = new Keyboard()));
context.subscriptions.splice(0, 0, (this._vsls = new VslsController(this)));
context.subscriptions.splice(0, 0, (this._eventBus = new EventBus()));
context.subscriptions.unshift((this._actionRunners = new ActionRunners(this)));
context.subscriptions.unshift((this._tracker = new GitDocumentTracker(this)));
context.subscriptions.unshift((this._lineTracker = new GitLineTracker(this)));
context.subscriptions.unshift((this._keyboard = new Keyboard()));
context.subscriptions.unshift((this._vsls = new VslsController(this)));
context.subscriptions.unshift((this._eventBus = new EventBus()));
context.subscriptions.splice(0, 0, (this._fileAnnotationController = new FileAnnotationController(this)));
context.subscriptions.splice(0, 0, (this._lineAnnotationController = new LineAnnotationController(this)));
context.subscriptions.splice(0, 0, (this._lineHoverController = new LineHoverController(this)));
context.subscriptions.splice(0, 0, (this._statusBarController = new StatusBarController(this)));
context.subscriptions.splice(0, 0, (this._codeLensController = new GitCodeLensController(this)));
context.subscriptions.unshift((this._fileAnnotationController = new FileAnnotationController(this)));
context.subscriptions.unshift((this._lineAnnotationController = new LineAnnotationController(this)));
context.subscriptions.unshift((this._lineHoverController = new LineHoverController(this)));
context.subscriptions.unshift((this._statusBarController = new StatusBarController(this)));
context.subscriptions.unshift((this._codeLensController = new GitCodeLensController(this)));
context.subscriptions.splice(0, 0, (this._webviews = new WebviewsController(this)));
context.subscriptions.splice(0, 0, registerTimelineWebviewPanel(this._webviews));
context.subscriptions.splice(0, 0, (this._timelineView = registerTimelineWebviewView(this._webviews)));
context.subscriptions.unshift((this._webviews = new WebviewsController(this)));
context.subscriptions.unshift(registerTimelineWebviewPanel(this._webviews));
context.subscriptions.unshift((this._timelineView = registerTimelineWebviewView(this._webviews)));
const graphWebviewPanel = registerGraphWebviewPanel(this._webviews);
context.subscriptions.splice(0, 0, graphWebviewPanel);
context.subscriptions.splice(0, 0, registerGraphWebviewCommands(graphWebviewPanel));
// context.subscriptions.splice(0, 0, (this._graphView = registerGraphWebviewView(this._webviews)));
context.subscriptions.splice(0, 0, new GraphStatusBarController(this));
context.subscriptions.unshift(graphWebviewPanel);
context.subscriptions.unshift(registerGraphWebviewCommands(graphWebviewPanel));
// context.subscriptions.unshift((this._graphView = registerGraphWebviewView(this._webviews)));
context.subscriptions.unshift(new GraphStatusBarController(this));
const settingsWebviewPanel = registerSettingsWebviewPanel(this._webviews);
context.subscriptions.splice(0, 0, settingsWebviewPanel);
context.subscriptions.splice(0, 0, registerSettingsWebviewCommands(settingsWebviewPanel));
context.subscriptions.splice(0, 0, registerWelcomeWebviewPanel(this._webviews));
context.subscriptions.splice(0, 0, (this._rebaseEditor = new RebaseEditorProvider(this)));
context.subscriptions.splice(0, 0, registerFocusWebviewPanel(this._webviews));
context.subscriptions.splice(0, 0, new ViewFileDecorationProvider());
context.subscriptions.splice(0, 0, (this._repositoriesView = new RepositoriesView(this)));
context.subscriptions.splice(
0,
0,
(this._commitDetailsView = registerCommitDetailsWebviewView(this._webviews)),
);
context.subscriptions.splice(0, 0, (this._commitsView = new CommitsView(this)));
context.subscriptions.splice(0, 0, (this._fileHistoryView = new FileHistoryView(this)));
context.subscriptions.splice(0, 0, (this._lineHistoryView = new LineHistoryView(this)));
context.subscriptions.splice(0, 0, (this._branchesView = new BranchesView(this)));
context.subscriptions.splice(0, 0, (this._remotesView = new RemotesView(this)));
context.subscriptions.splice(0, 0, (this._stashesView = new StashesView(this)));
context.subscriptions.splice(0, 0, (this._tagsView = new TagsView(this)));
context.subscriptions.splice(0, 0, (this._worktreesView = new WorktreesView(this)));
context.subscriptions.splice(0, 0, (this._contributorsView = new ContributorsView(this)));
context.subscriptions.splice(0, 0, (this._searchAndCompareView = new SearchAndCompareView(this)));
context.subscriptions.splice(0, 0, (this._homeView = registerHomeWebviewView(this._webviews)));
context.subscriptions.unshift(settingsWebviewPanel);
context.subscriptions.unshift(registerSettingsWebviewCommands(settingsWebviewPanel));
context.subscriptions.unshift(registerWelcomeWebviewPanel(this._webviews));
context.subscriptions.unshift((this._rebaseEditor = new RebaseEditorProvider(this)));
context.subscriptions.unshift(registerFocusWebviewPanel(this._webviews));
context.subscriptions.unshift(new ViewFileDecorationProvider());
context.subscriptions.unshift((this._repositoriesView = new RepositoriesView(this)));
context.subscriptions.unshift((this._commitDetailsView = registerCommitDetailsWebviewView(this._webviews)));
context.subscriptions.unshift((this._commitsView = new CommitsView(this)));
context.subscriptions.unshift((this._fileHistoryView = new FileHistoryView(this)));
context.subscriptions.unshift((this._lineHistoryView = new LineHistoryView(this)));
context.subscriptions.unshift((this._branchesView = new BranchesView(this)));
context.subscriptions.unshift((this._remotesView = new RemotesView(this)));
context.subscriptions.unshift((this._stashesView = new StashesView(this)));
context.subscriptions.unshift((this._tagsView = new TagsView(this)));
context.subscriptions.unshift((this._worktreesView = new WorktreesView(this)));
context.subscriptions.unshift((this._contributorsView = new ContributorsView(this)));
context.subscriptions.unshift((this._searchAndCompareView = new SearchAndCompareView(this)));
context.subscriptions.unshift((this._homeView = registerHomeWebviewView(this._webviews)));
if (configuration.get('terminalLinks.enabled')) {
context.subscriptions.splice(0, 0, (this._terminalLinks = new GitTerminalLinkProvider(this)));
context.subscriptions.unshift((this._terminalLinks = new GitTerminalLinkProvider(this)));
}
context.subscriptions.splice(
0,
0,
context.subscriptions.unshift(
configuration.onDidChange(e => {
if (!configuration.changed(e, 'terminalLinks.enabled')) return;
this._terminalLinks?.dispose();
if (configuration.get('terminalLinks.enabled')) {
context.subscriptions.splice(0, 0, (this._terminalLinks = new GitTerminalLinkProvider(this)));
context.subscriptions.unshift((this._terminalLinks = new GitTerminalLinkProvider(this)));
}
}),
);
@ -287,7 +279,7 @@ export class Container {
private async registerGitProviders() {
const providers = await getSupportedGitProviders(this);
for (const provider of providers) {
this._context.subscriptions.splice(0, 0, this._git.register(provider.descriptor.id, provider));
this._context.subscriptions.unshift(this._git.register(provider.descriptor.id, provider));
}
this._git.registrationComplete();
@ -312,7 +304,7 @@ export class Container {
private _actionRunners: ActionRunners;
get actionRunners() {
if (this._actionRunners == null) {
this._context.subscriptions.splice(0, 0, (this._actionRunners = new ActionRunners(this)));
this._context.subscriptions.unshift((this._actionRunners = new ActionRunners(this)));
}
return this._actionRunners;
@ -321,7 +313,7 @@ export class Container {
private _autolinks: Autolinks | undefined;
get autolinks() {
if (this._autolinks == null) {
this._context.subscriptions.splice(0, 0, (this._autolinks = new Autolinks(this)));
this._context.subscriptions.unshift((this._autolinks = new Autolinks(this)));
}
return this._autolinks;
@ -335,7 +327,7 @@ export class Container {
private _branchesView: BranchesView | undefined;
get branchesView() {
if (this._branchesView == null) {
this._context.subscriptions.splice(0, 0, (this._branchesView = new BranchesView(this)));
this._context.subscriptions.unshift((this._branchesView = new BranchesView(this)));
}
return this._branchesView;
@ -344,7 +336,7 @@ export class Container {
private _commitsView: CommitsView | undefined;
get commitsView() {
if (this._commitsView == null) {
this._context.subscriptions.splice(0, 0, (this._commitsView = new CommitsView(this)));
this._context.subscriptions.unshift((this._commitsView = new CommitsView(this)));
}
return this._commitsView;
@ -363,7 +355,7 @@ export class Container {
private _contributorsView: ContributorsView | undefined;
get contributorsView() {
if (this._contributorsView == null) {
this._context.subscriptions.splice(0, 0, (this._contributorsView = new ContributorsView(this)));
this._context.subscriptions.unshift((this._contributorsView = new ContributorsView(this)));
}
return this._contributorsView;
@ -398,7 +390,7 @@ export class Container {
private _fileHistoryView: FileHistoryView | undefined;
get fileHistoryView() {
if (this._fileHistoryView == null) {
this._context.subscriptions.splice(0, 0, (this._fileHistoryView = new FileHistoryView(this)));
this._context.subscriptions.unshift((this._fileHistoryView = new FileHistoryView(this)));
}
return this._fileHistoryView;
@ -431,7 +423,7 @@ export class Container {
private async _loadGitHubApi() {
try {
const github = new (await import(/* webpackChunkName: "github" */ './plus/github/github')).GitHubApi(this);
this._context.subscriptions.splice(0, 0, github);
this._context.subscriptions.unshift(github);
return github;
} catch (ex) {
Logger.error(ex);
@ -451,7 +443,7 @@ export class Container {
private async _loadGitLabApi() {
try {
const gitlab = new (await import(/* webpackChunkName: "gitlab" */ './plus/gitlab/gitlab')).GitLabApi(this);
this._context.subscriptions.splice(0, 0, gitlab);
this._context.subscriptions.unshift(gitlab);
return gitlab;
} catch (ex) {
Logger.error(ex);
@ -477,9 +469,7 @@ export class Container {
private _integrationAuthentication: IntegrationAuthenticationService | undefined;
get integrationAuthentication() {
if (this._integrationAuthentication == null) {
this._context.subscriptions.splice(
0,
0,
this._context.subscriptions.unshift(
(this._integrationAuthentication = new IntegrationAuthenticationService(this)),
// Register any integration authentication providers
new GitHubAuthenticationProvider(this),
@ -503,7 +493,7 @@ export class Container {
private _lineHistoryView: LineHistoryView | undefined;
get lineHistoryView() {
if (this._lineHistoryView == null) {
this._context.subscriptions.splice(0, 0, (this._lineHistoryView = new LineHistoryView(this)));
this._context.subscriptions.unshift((this._lineHistoryView = new LineHistoryView(this)));
}
return this._lineHistoryView;
@ -532,7 +522,7 @@ export class Container {
private _rebaseEditor: RebaseEditorProvider | undefined;
get rebaseEditor() {
if (this._rebaseEditor == null) {
this._context.subscriptions.splice(0, 0, (this._rebaseEditor = new RebaseEditorProvider(this)));
this._context.subscriptions.unshift((this._rebaseEditor = new RebaseEditorProvider(this)));
}
return this._rebaseEditor;
@ -541,7 +531,7 @@ export class Container {
private _remotesView: RemotesView | undefined;
get remotesView() {
if (this._remotesView == null) {
this._context.subscriptions.splice(0, 0, (this._remotesView = new RemotesView(this)));
this._context.subscriptions.unshift((this._remotesView = new RemotesView(this)));
}
return this._remotesView;
@ -550,7 +540,7 @@ export class Container {
private _repositoriesView: RepositoriesView | undefined;
get repositoriesView(): RepositoriesView {
if (this._repositoriesView == null) {
this._context.subscriptions.splice(0, 0, (this._repositoriesView = new RepositoriesView(this)));
this._context.subscriptions.unshift((this._repositoriesView = new RepositoriesView(this)));
}
return this._repositoriesView;
@ -559,7 +549,7 @@ export class Container {
private _searchAndCompareView: SearchAndCompareView | undefined;
get searchAndCompareView() {
if (this._searchAndCompareView == null) {
this._context.subscriptions.splice(0, 0, (this._searchAndCompareView = new SearchAndCompareView(this)));
this._context.subscriptions.unshift((this._searchAndCompareView = new SearchAndCompareView(this)));
}
return this._searchAndCompareView;
@ -583,7 +573,7 @@ export class Container {
private _stashesView: StashesView | undefined;
get stashesView() {
if (this._stashesView == null) {
this._context.subscriptions.splice(0, 0, (this._stashesView = new StashesView(this)));
this._context.subscriptions.unshift((this._stashesView = new StashesView(this)));
}
return this._stashesView;
@ -602,7 +592,7 @@ export class Container {
private _tagsView: TagsView | undefined;
get tagsView() {
if (this._tagsView == null) {
this._context.subscriptions.splice(0, 0, (this._tagsView = new TagsView(this)));
this._context.subscriptions.unshift((this._tagsView = new TagsView(this)));
}
return this._tagsView;
@ -649,7 +639,7 @@ export class Container {
private _worktreesView: WorktreesView | undefined;
get worktreesView() {
if (this._worktreesView == null) {
this._context.subscriptions.splice(0, 0, (this._worktreesView = new WorktreesView(this)));
this._context.subscriptions.unshift((this._worktreesView = new WorktreesView(this)));
}
return this._worktreesView;

+ 4
- 8
src/env/node/git/git.ts Zobrazit soubor

@ -143,9 +143,7 @@ export class Git {
// Fixes https://github.com/gitkraken/vscode-gitlens/issues/73 & https://github.com/gitkraken/vscode-gitlens/issues/161
// See https://stackoverflow.com/questions/4144417/how-to-handle-asian-characters-in-file-names-in-git-on-os-x
args.splice(
0,
0,
args.unshift(
'-c',
'core.quotepath=false',
'-c',
@ -154,7 +152,7 @@ export class Git {
);
if (process.platform === 'win32') {
args.splice(0, 0, '-c', 'core.longpaths=true');
args.unshift('-c', 'core.longpaths=true');
}
promise = run<T>(await this.path(), args, encoding ?? 'utf8', runOpts);
@ -240,9 +238,7 @@ export class Git {
// Fixes https://github.com/gitkraken/vscode-gitlens/issues/73 & https://github.com/gitkraken/vscode-gitlens/issues/161
// See https://stackoverflow.com/questions/4144417/how-to-handle-asian-characters-in-file-names-in-git-on-os-x
args.splice(
0,
0,
args.unshift(
'-c',
'core.quotepath=false',
'-c',
@ -251,7 +247,7 @@ export class Git {
);
if (process.platform === 'win32') {
args.splice(0, 0, '-c', 'core.longpaths=true');
args.unshift('-c', 'core.longpaths=true');
}
if (cancellation) {

+ 1
- 1
src/quickpicks/modePicker.ts Zobrazit soubor

@ -27,7 +27,7 @@ export async function showModePicker(): Promise
});
if (mode && modes[mode] != null) {
items.splice(0, 0, {
items.unshift({
label: `Exit ${modes[mode].name} mode`,
key: undefined,
});

+ 3
- 3
src/quickpicks/referencePicker.ts Zobrazit soubor

@ -191,16 +191,16 @@ async function getItems(
if (picked) {
const index = items.findIndex(i => i.ref === picked);
if (index !== -1) {
items.splice(0, 0, ...items.splice(index, 1));
items.unshift(...items.splice(index, 1));
}
}
if (include & ReferencesQuickPickIncludes.HEAD) {
items.splice(0, 0, createRefQuickPickItem('HEAD', repoPath, undefined, { icon: true }));
items.unshift(createRefQuickPickItem('HEAD', repoPath, undefined, { icon: true }));
}
if (include & ReferencesQuickPickIncludes.WorkingTree) {
items.splice(0, 0, createRefQuickPickItem('', repoPath, undefined, { icon: true }));
items.unshift(createRefQuickPickItem('', repoPath, undefined, { icon: true }));
}
return items;

+ 1
- 3
src/views/nodes/branchTrackingStatusNode.ts Zobrazit soubor

@ -135,9 +135,7 @@ export class BranchTrackingStatusNode extends ViewNode impleme
}
if (showFiles) {
children.splice(
0,
0,
children.unshift(
new BranchTrackingStatusFilesNode(
this.view,
this,

+ 2
- 4
src/views/nodes/commitNode.ts Zobrazit soubor

@ -105,9 +105,7 @@ export class CommitNode extends ViewRefNode
// If we found a pull request, insert it into the children cache (if loaded) and refresh the node
if (pr != null && this._children != null) {
this._children.splice(
0,
0,
this._children.unshift(
new PullRequestNode(this.view as ViewsWithCommits, this, pr, commit),
);
}
@ -140,7 +138,7 @@ export class CommitNode extends ViewRefNode
}
if (pullRequest != null) {
children.splice(0, 0, new PullRequestNode(this.view as ViewsWithCommits, this, pullRequest, commit));
children.unshift(new PullRequestNode(this.view as ViewsWithCommits, this, pullRequest, commit));
}
this._children = children;

+ 1
- 3
src/views/nodes/lineHistoryNode.ts Zobrazit soubor

@ -117,9 +117,7 @@ export class LineHistoryNode
const pseudoCommits = status?.getPseudoCommits(this.view.container, currentUser);
if (pseudoCommits != null) {
for (const commit of pseudoCommits.reverse()) {
children.splice(
0,
0,
children.unshift(
new FileRevisionAsCommitNode(this.view, this, file, commit, {
selection: selection,
}),

+ 1
- 1
src/views/nodes/rebaseStatusNode.ts Zobrazit soubor

@ -74,7 +74,7 @@ export class RebaseStatusNode extends ViewNode {
this.rebaseStatus.steps.current.commit.ref,
);
if (commit != null) {
children.splice(0, 0, new RebaseCommitNode(this.view, this, commit) as any);
children.unshift(new RebaseCommitNode(this.view, this, commit) as any);
}
return children;

+ 1
- 3
src/views/nodes/statusFilesNode.ts Zobrazit soubor

@ -76,9 +76,7 @@ export class StatusFilesNode extends ViewNode
(this.view instanceof WorktreesView || this.view.config.includeWorkingTree) &&
this.status.files.length !== 0
) {
files.splice(
0,
0,
files.unshift(
...flatMap(this.status.files, f =>
map(f.getPseudoCommits(this.view.container, undefined), c => this.getFileWithPseudoCommit(f, c)),
),

+ 1
- 1
src/views/nodes/worktreeNode.ts Zobrazit soubor

@ -179,7 +179,7 @@ export class WorktreeNode extends ViewNode
const status = getSettledValue(statusResult);
if (status?.hasChanges) {
children.splice(0, 0, new UncommittedFilesNode(this.view, this, status, undefined));
children.unshift(new UncommittedFilesNode(this.view, this, status, undefined));
}
this._children = children;

+ 1
- 1
src/views/searchAndCompareView.ts Zobrazit soubor

@ -212,7 +212,7 @@ export class SearchAndCompareViewNode extends ViewNode {
repoPath: repoPath,
ref: ref,
});
this.children.splice(0, 0, this.comparePicker);
this.children.unshift(this.comparePicker);
void setContext(ContextKeys.ViewsCanCompare, true);
await this.triggerChange();

Načítá se…
Zrušit
Uložit