Browse Source

Ensures open changes only added to file commits

Updates CHANGELOG & README
Refs: #2641
main
Eric Amodio 1 year ago
parent
commit
03f5092719
3 changed files with 38 additions and 25 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +1
    -0
      README.md
  3. +33
    -25
      src/commands/quickCommand.steps.ts

+ 4
- 0
CHANGELOG.md View File

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds an _Open Changes_ button to commits in the file history quick pick menu — closes [#2641](https://github.com/gitkraken/vscode-gitlens/issues/2641) thanks to [PR #2800](https://github.com/gitkraken/vscode-gitlens/pull/2800) by Omar Ghazi ([@omarfesal](https://github.com/omarfesal))
## [14.2.1] - 2023-08-10
### Added

+ 1
- 0
README.md View File

@ -345,6 +345,7 @@ A big thanks to the people that have contributed to this project 🙏❤️:
- Cory Forsyth ([@bantic](https://github.com/bantic)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=bantic)
- John Gee ([@shadowspawn](https://github.com/shadowspawn)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=shadowspawn)
- Geoffrey ([@g3offrey](https://github.com/g3offrey)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=g3offrey)
- Omar Ghazi ([@omarfesal](https://github.com/omarfesal)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=omarfesal)
- Neil Ghosh ([@neilghosh](https://github.com/neilghosh)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=neilghosh)
- Guillaume Rozan ([@grozan](https://github.com/grozan)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=grozan)
- Guillem González Vela ([@guillemglez](https://github.com/guillemglez)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=guillemglez)

+ 33
- 25
src/commands/quickCommand.steps.ts View File

@ -98,7 +98,7 @@ import { isSubscriptionPaidPlan, isSubscriptionPreviewTrialExpired } from '../su
import { filterMap, intersection, isStringArray } from '../system/array';
import { configuration } from '../system/configuration';
import { formatPath } from '../system/formatPath';
import { map } from '../system/iterable';
import { first, map } from '../system/iterable';
import { getSettledValue } from '../system/promise';
import { pad, pluralize, truncate } from '../system/string';
import { openWorkspace, OpenWorkspaceLocation } from '../system/utils';
@ -1059,27 +1059,32 @@ export async function* pickCommitStep<
},
): AsyncStepResultGenerator<GitCommit> {
function getItems(log: GitLog | undefined) {
return log == null
? [createDirectiveQuickPickItem(Directive.Back, true), createDirectiveQuickPickItem(Directive.Cancel)]
: [
...map(log.commits.values(), commit =>
createCommitQuickPickItem(
commit,
picked != null &&
(typeof picked === 'string' ? commit.ref === picked : picked.includes(commit.ref)),
{
buttons: [
ShowDetailsViewQuickInputButton,
RevealInSideBarQuickInputButton,
OpenChangesViewQuickInputButton,
],
compact: true,
icon: true,
},
),
),
...(log?.hasMore ? [createDirectiveQuickPickItem(Directive.LoadMore)] : []),
];
if (log == null) {
return [createDirectiveQuickPickItem(Directive.Back, true), createDirectiveQuickPickItem(Directive.Cancel)];
}
const buttons = [ShowDetailsViewQuickInputButton, RevealInSideBarQuickInputButton];
// If these are "file" commits, then add an Open Changes button
if (first(log.commits)?.[1].file != null) {
buttons.splice(0, 0, OpenChangesViewQuickInputButton);
}
return [
...map(log.commits.values(), commit =>
createCommitQuickPickItem(
commit,
picked != null &&
(typeof picked === 'string' ? commit.ref === picked : picked.includes(commit.ref)),
{
buttons: buttons,
compact: true,
icon: true,
},
),
),
...(log?.hasMore ? [createDirectiveQuickPickItem(Directive.LoadMore)] : []),
];
}
const step = createPickStep<CommandQuickPickItem | CommitQuickPickItem>({
@ -1106,7 +1111,6 @@ export async function* pickCommitStep<
],
onDidClickItemButton: (quickpick, button, item) => {
if (CommandQuickPickItem.is(item)) return;
const fileName = `${item.item.file?.path}`;
switch (button) {
case ShowDetailsViewQuickInputButton:
@ -1120,9 +1124,13 @@ export async function* pickCommitStep<
expand: true,
});
break;
case OpenChangesViewQuickInputButton:
void CommitActions.openChanges(fileName, item.item, {});
case OpenChangesViewQuickInputButton: {
const path = item.item.file?.path;
if (path != null) {
void CommitActions.openChanges(path, item.item);
}
break;
}
}
},
onDidClickButton: (quickpick, button) => {

Loading…
Cancel
Save