From 63a17deff3f21d3f98dcc99f6673ac7272dcfeb3 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 10 Nov 2018 17:40:53 -0500 Subject: [PATCH] Renames Results view files to Compare view Updates README (wip) Updates welcome & settings pages (wip) --- README.md | 137 ++++++++++------- package.json | 242 ++++++++++++++++--------------- src/commands/common.ts | 2 +- src/commands/diffBranchWithBranch.ts | 2 +- src/commands/diffDirectory.ts | 6 +- src/commands/showCommitSearch.ts | 2 +- src/commands/showView.ts | 12 +- src/configuration.ts | 3 +- src/constants.ts | 4 +- src/container.ts | 55 ++++--- src/extension.ts | 34 +++++ src/quickpicks/commitsQuickPick.ts | 6 +- src/ui/config.ts | 4 +- src/ui/settings/index.html | 141 +++++++++++++----- src/ui/welcome/index.html | 13 +- src/views/compareView.ts | 135 +++++++++++++++++ src/views/nodes.ts | 8 +- src/views/nodes/compareNode.ts | 171 ++++++++++++++++++++++ src/views/nodes/comparePickerNode.ts | 14 +- src/views/nodes/compareResultsNode.ts | 84 +++++++++++ src/views/nodes/resultsComparisonNode.ts | 84 ----------- src/views/nodes/resultsNode.ts | 169 --------------------- src/views/nodes/searchNode.ts | 2 +- src/views/nodes/viewNode.ts | 6 +- src/views/resultsView.ts | 135 ----------------- src/views/viewBase.ts | 4 +- src/views/viewCommands.ts | 12 +- 27 files changed, 818 insertions(+), 669 deletions(-) create mode 100644 src/views/compareView.ts create mode 100644 src/views/nodes/compareNode.ts create mode 100644 src/views/nodes/compareResultsNode.ts delete mode 100644 src/views/nodes/resultsComparisonNode.ts delete mode 100644 src/views/nodes/resultsNode.ts delete mode 100644 src/views/resultsView.ts diff --git a/README.md b/README.md index 406f29b..1798135 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,8 @@ Here are just some of the features that GitLens provides, - a [_Repositories_ view](#repositories-view 'Jump to the Repositories view') to visualize, navigate, and explore Git repositories - a [_File History_ view](#file-history-view 'Jump to the File History view') to visualize, navigate, and explore the revision history of the current file - a [_Line History_ view](#line-history-view 'Jump to the Line History view') to visualize, navigate, and explore the revision history of the selected lines of current file -- an on-demand [_Results_ view](#results-view 'Jump to the Results view') to navigate and explore commits, histories, and searches, or visualize comparisons between branches, tags, commits, and more +- a [_Compare_ view](#compare-view 'Jump to the Compare view') to visualize comparisons between branches, tags, commits, and more +- a [Search Commits view](#search-commits-view 'Jump to the Search Commits view') to search and explore commit histories by message, author, files, id, etc - [authorship code lens](#code-lens 'Jump to the Code Lens') showing the most recent commit and # of authors to the top of files and/or on code blocks - an unobtrusive [current line blame](#current-line-blame 'Jump to the Current Line Blame') annotation at the end of the line - on-demand [gutter blame](#gutter-blame 'Jump to the Gutter Blame') annotations, including a heatmap, for the whole file @@ -71,15 +72,15 @@ If you'd like to join them in supporting GitLens, please consider the following - [Star or Fork me on GitHub](https://github.com/eamodio/vscode-gitlens 'Star or fork me on GitHub') - [Follow me on Twitter](https://twitter.com/eamodio 'Follow me on Twitter') -#### Gold Sponsors ($100+) +#### Gold Sponsors (\$100+) None yet — could be you! -#### Silver Sponsors ($50+) +#### Silver Sponsors (\$50+) None yet — could be you! -#### Bronze Sponsors ($25+) +#### Bronze Sponsors (\$25+) None yet — could be you! @@ -205,7 +206,7 @@ A [customizable](#line-history-view-settings 'Jump to the Line History view sett - A toolbar provides a _Refresh_ command - A context menu provides a _Follow Renames_ or _Don't Follow Renames_ command -The line history explorer provides the following features, +The line history view provides the following features, - Automatically updates to track the selection of the current editor - A context menu provides _Open File_, _Open File on Remote_ (if available), _Copy Remote File Url to Clipboard_ (if available), and _Refresh_ commands @@ -215,35 +216,18 @@ The line history explorer provides the following features, --- -### Results view +### Compare view

- Results view + Compare view

-An on-demand, [customizable](#results-view-settings 'Jump to the Results view settings') view to navigate and explore commits, histories, and searches, or visualize comparisons between branches, tags, commits, and more +A [customizable](#compare-view-settings 'Jump to the Compare view settings') view to visualize comparisons between branches, tags, commits, and more -- A toolbar provides _Search Commits_, _Keep Results_, and _Refresh_ commands - - A context menu provides _Automatic Layout_, _List Layout_, _Tree Layout_, and _Close_ commands +- A toolbar provides _Clear Results_, _Keep Results_, and _Refresh_ commands + - A context menu provides _Automatic Layout_, _List Layout_, and _Tree Layout_ commands -The results view provides the following features, - -#### Explore - -- Provides a semi-persistent results view for exploring histories, commits, and searches - - Accessible via the following commands - - _Show Commit Search_ command (`gitlens.showCommitSearch`) - - _Show File History_ command (`gitlens.showQuickFileHistory`) - - _Show Commit Details_ command (`gitlens.showQuickCommitDetails`) - - An inline toolbar provides a _Clear Results_ command - - A context menu provides _Clear Results_, and _Refresh_ commands - - Revisions (commits) expand show the set of files changed, complete with status indicators for adds, changes, renames, and deletes - - Context menus for each revision (commit) provide - - _Open Commit on Remote_ (if available), _Open All Changes_, _Open All Changes with Working Tree_, _Open Files_, _Open Revisions_, _Copy Commit ID to Clipboard_, _Copy Commit Message to Clipboard_, _Show Commit Details_, _Compare with HEAD_, _Compare with Working Tree_, _Compare with Selected_ (when available), _Select for Compare_, _Cherry Pick Commit (via Terminal)_ (when available), _Push to Commit (via Terminal)_ (when available), _Revert Commit (via Terminal)_ (when available), _Checkout Commit (via Terminal)_, _Rebase to Commit (via Terminal)_, _Reset to Commit (via Terminal)_, _Create Branch (via Terminal)..._, _Create Tag (via Terminal)..._, and _Refresh_ commands - - Context menus for each changed file provide - - _Open Changes_, _Open Changes with Working File_, _Open File_, _Open Revision_, _Open File on Remote_, _Open Revision on Remote_, _Copy Commit ID to Clipboard_, _Copy Commit Message to Clipboard_, _Copy Remote File Url to Clipboard_, _Apply Changes_, _Compare with Selected_ (when available), _Select for Compare_, and _Show Commit File Details_ commands - -#### Compare +The compare view provides the following features, - Provides a semi-persistent results view for comparison operations @@ -268,6 +252,34 @@ The results view provides the following features, --- +### Search Commits view + +

+ Search Commits view +

+ +A [customizable](#search-commits-view-settings 'Jump to the Search Commits view settings') view to search and explore commit histories by message, author, files, id, etc + +- A toolbar provides _Clear Results_, _Keep Results_, and _Refresh_ commands + - A context menu provides _Automatic Layout_, _List Layout_, and _Tree Layout_ commands + +The search commits view provides the following features, + +- Provides a semi-persistent results view for searching and exploring commit histories + - Accessible via the following commands + - _Show Commit Search_ command (`gitlens.showCommitSearch`) + - _Show File History_ command (`gitlens.showQuickFileHistory`) + - _Show Commit Details_ command (`gitlens.showQuickCommitDetails`) + - An inline toolbar provides a _Clear Results_ command + - A context menu provides _Clear Results_, and _Refresh_ commands + - Revisions (commits) expand show the set of files changed, complete with status indicators for adds, changes, renames, and deletes + - Context menus for each revision (commit) provide + - _Open Commit on Remote_ (if available), _Open All Changes_, _Open All Changes with Working Tree_, _Open Files_, _Open Revisions_, _Copy Commit ID to Clipboard_, _Copy Commit Message to Clipboard_, _Show Commit Details_, _Compare with HEAD_, _Compare with Working Tree_, _Compare with Selected_ (when available), _Select for Compare_, _Cherry Pick Commit (via Terminal)_ (when available), _Push to Commit (via Terminal)_ (when available), _Revert Commit (via Terminal)_ (when available), _Checkout Commit (via Terminal)_, _Rebase to Commit (via Terminal)_, _Reset to Commit (via Terminal)_, _Create Branch (via Terminal)..._, _Create Tag (via Terminal)..._, and _Refresh_ commands + - Context menus for each changed file provide + - _Open Changes_, _Open Changes with Working File_, _Open File_, _Open Revision_, _Open File on Remote_, _Open Revision on Remote_, _Copy Commit ID to Clipboard_, _Copy Commit Message to Clipboard_, _Copy Remote File Url to Clipboard_, _Apply Changes_, _Compare with Selected_ (when available), _Select for Compare_, and _Show Commit File Details_ commands + +--- + ### Code Lens

@@ -454,7 +466,7 @@ The results view provides the following features, - Use `#` to search for a commit with id of `` — See [Git docs](https://git-scm.com/docs/git-log 'Open Git docs') - Use `~` to search for commits with differences whose patch text contains added/removed lines that match `` — See [Git docs](https://git-scm.com/docs/git-log#git-log--Gltregexgt 'Open Git docs') - Use `=` to search for commits with differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file — See [Git docs](https://git-scm.com/docs/git-log#git-log--Sltstringgt 'Open Git docs') - - Provides a _Show in Results_ option to show the search results in the _Results_ view + - Provides a _Show in View_ option to show the search results in the _Search Commits_ view --- @@ -492,7 +504,7 @@ The results view provides the following features,

- Adds a _Show File History_ command (`gitlens.showQuickFileHistory`) to show a paged **file history quick pick menu** of the current file for exploring its commit history - - Provides additional entries to _Show in Results_, _Show Branch History_, and _Open File on \_ when available + - Provides additional entries to _Show in View_, _Show Branch History_, and _Open File on \_ when available - Navigate back to the previous quick pick menu via `alt+left arrow`, if available - Navigate pages via `alt+,` and `alt+.` to go backward and forward respectively @@ -504,7 +516,7 @@ The results view provides the following features, - Adds a _Show Commit Details_ command (`gitlens.showQuickCommitDetails`) to show a **commit details quick pick menu** of the most recent commit of the current file - Quickly see the set of files changed in the commit, complete with status indicators for adds, changes, renames, and deletes - - Provides additional entries to _Show in Results_, _Open Commit on \_ when available, _Open Files_, _Open Revisions_, _Open Directory Compare with Previous Revision_, _Open Directory Compare with Working Tree_, _Copy Commit ID to Clipboard_, _Copy Commit Message to Clipboard_ + - Provides additional entries to _Show in View_, _Open Commit on \_ when available, _Open Files_, _Open Revisions_, _Open Directory Compare with Previous Revision_, _Open Directory Compare with Working Tree_, _Copy Commit ID to Clipboard_, _Copy Commit Message to Clipboard_ - Navigate back to the previous quick pick menu via `alt+left arrow`, if available - Use the `alt+right arrow` shortcut on an entry to execute it without closing the quick pick menu, if possible — commands that open windows outside of VS Code will still close the quick pick menu unless [`"gitlens.advanced.quickPick.closeOnFocusOut": false`](#advanced-settings 'Jump to Advanced settings') is set - Use the `alt+right arrow` shortcut on a file entry in the `Changed Files` section to preview the comparison of the current revision with the previous one @@ -649,51 +661,64 @@ See also [View Settings](#view-settings 'Jump to the View settings') | `gitlens.views.repositories.files.layout` | Specifies how the _Repositories_ view will display files
`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.views.repositories.files.threshold` value and the number of files at each nesting level
`list` - displays files as a list
`tree` - displays files as a tree | | `gitlens.views.repositories.files.threshold` | Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _Repositories_ view
Only applies when `gitlens.views.repositories.files.layout` is set to `auto` | | `gitlens.views.repositories.includeWorkingTree` | Specifies whether to include working tree files inside the `Repository Status` node of the _Repositories_ view | -| `gitlens.views.repositories.location` | Specifies where to show the _Repositories_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view | +| `gitlens.views.repositories.location` | Specifies where to show the _Repositories_ view
`gitlens` - adds to the GitLens side bar
`explorer` - adds to the Explorer side bar
`scm` - adds to the Source Control side bar | | `gitlens.views.repositories.showTrackingBranch` | Specifies whether to show the tracking branch when displaying local branches in the _Repositories_ view | ### File History View Settings See also [View Settings](#view-settings 'Jump to the View settings') -| Name | Description | -| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `gitlens.views.fileHistory.avatars` | Specifies whether to show avatar images instead of status icons in the _File History_ view | -| `gitlens.views.fileHistory.enabled` | Specifies whether to show the _File History_ view | -| `gitlens.views.fileHistory.location` | Specifies where to show the _File History_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view | +| Name | Description | +| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.views.fileHistory.avatars` | Specifies whether to show avatar images instead of status icons in the _File History_ view | +| `gitlens.views.fileHistory.enabled` | Specifies whether to show the _File History_ view | +| `gitlens.views.fileHistory.location` | Specifies where to show the _File History_ view
`gitlens` - adds to the GitLens side bar
`explorer` - adds to the Explorer side bar
`scm` - adds to the Source Control side bar | ### Line History View Settings See also [View Settings](#view-settings 'Jump to the View settings') -| Name | Description | -| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `gitlens.views.lineHistory.avatars` | Specifies whether to show avatar images instead of status icons in the _Line History_ view | -| `gitlens.views.lineHistory.enabled` | Specifies whether to show the _Line History_ view | -| `gitlens.views.lineHistory.location` | Specifies where to show the _Line History_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view | +| Name | Description | +| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.views.lineHistory.avatars` | Specifies whether to show avatar images instead of status icons in the _Line History_ view | +| `gitlens.views.lineHistory.enabled` | Specifies whether to show the _Line History_ view | +| `gitlens.views.lineHistory.location` | Specifies where to show the _Line History_ view
`gitlens` - adds to the GitLens side bar
`explorer` - adds to the Explorer side bar
`scm` - adds to the Source Control side bar | -### Results View Settings +### Compare View Settings See also [View Settings](#view-settings 'Jump to the View settings') | Name | Description | | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `gitlens.views.results.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _Results_ view
Only applies when `gitlens.views.results.files.layout` is set to `tree` or `auto` | -| `gitlens.views.results.files.layout` | Specifies how the _Results_ view will display files
`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.views.results.files.threshold` value and the number of files at each nesting level
`list` - displays files as a list
`tree` - displays files as a tree | -| `gitlens.views.results.files.threshold` | Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _Results_ view
Only applies when `gitlens.views.results.files.layout` is set to `auto` | -| `gitlens.views.results.location` | Specifies where to show the _Results_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view | +| `gitlens.views.compare.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _Compare_ view
Only applies when `gitlens.views.compare.files.layout` is set to `tree` or `auto` | +| `gitlens.views.compare.enabled` | Specifies whether to show the _Compare_ view | +| `gitlens.views.compare.files.layout` | Specifies how the _Compare_ view will display files
`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.views.compare.files.threshold` value and the number of files at each nesting level
`list` - displays files as a list
`tree` - displays files as a tree | +| `gitlens.views.compare.files.threshold` | Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _Compare_ view
Only applies when `gitlens.views.compare.files.layout` is set to `auto` | +| `gitlens.views.compare.location` | Specifies where to show the _Compare_ view
`gitlens` - adds to the GitLens side bar
`explorer` - adds to the Explorer side bar
`scm` - adds to the Source Control side bar | + +### Search View Settings + +See also [View Settings](#view-settings 'Jump to the View settings') + +| Name | Description | +| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.views.search.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _Search Commits_ view
Only applies when `gitlens.views.compare.files.layout` is set to `tree` or `auto` | +| `gitlens.views.search.enabled` | Specifies whether to show the _Search Commits_ view | +| `gitlens.views.search.files.layout` | Specifies how the _Search Commits_ view will display files
`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.views.compare.files.threshold` value and the number of files at each nesting level
`list` - displays files as a list
`tree` - displays files as a tree | +| `gitlens.views.compare.files.threshold` | Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _Search Commits_ view
Only applies when `gitlens.views.compare.files.layout` is set to `auto` | +| `gitlens.views.search.location` | Specifies where to show the _Search Commits_ view
`gitlens` - adds to the GitLens side bar
`explorer` - adds to the Explorer side bar
`scm` - adds to the Source Control side bar | ### View Settings -| Name | Description | -| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `gitlens.views.avatars` | Specifies whether to show avatar images instead of commit (or status) icons in the _Repositories_ and _Results_ views | -| `gitlens.views.commitFileFormat` | Specifies the format of a committed file in the _Repositories_ and _Results_ views
Available tokens
${directory} - directory name
${file} - file name
${filePath} - formatted file name and path
${path} - full file path | -| `gitlens.views.commitFormat` | Specifies the format of committed changes in the _Repositories_ and _Results_ views
Available tokens
${id} - commit id
${author} - commit author
${message} - commit message
${ago} - relative commit date (e.g. 1 day ago)
${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)
${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`
${authorAgo} - commit author, relative commit date
${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`
See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting | -| `gitlens.views.defaultItemLimit` | Specifies the default number of items to show in a view list. Use 0 to specify no limit | -| `gitlens.views.stashFileFormat` | Specifies the format of a stashed file in the _Repositories_ and _Results_ views
Available tokens
${directory} - directory name
${file} - file name
${filePath} - formatted file name and path
${path} - full file path | -| `gitlens.views.stashFormat` | Specifies the format of stashed changes in the _Repositories_ and _Results_ views
Available tokens
${id} - commit id
${author} - commit author
${message} - commit message
${ago} - relative commit date (e.g. 1 day ago)
${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)
${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`
${authorAgo} - commit author, relative commit date
${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`
See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting | -| `gitlens.views.statusFileFormat` | Specifies the format of the status of a working or committed file in the _Repositories_ view
Available tokens
${directory} - directory name
${file} - file name
${filePath} - formatted file name and path
${path} - full file path
${working} - optional indicator if the file is uncommitted | +| Name | Description | +| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.views.avatars` | Specifies whether to show avatar images instead of commit (or status) icons in the views | +| `gitlens.views.commitFileFormat` | Specifies the format of a committed file in the views
Available tokens
${directory} - directory name
${file} - file name
${filePath} - formatted file name and path
${path} - full file path | +| `gitlens.views.commitFormat` | Specifies the format of committed changes in the views
Available tokens
${id} - commit id
${author} - commit author
${message} - commit message
${ago} - relative commit date (e.g. 1 day ago)
\${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)
\${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`
${authorAgo} - commit author, relative commit date
${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`
See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting | +| `gitlens.views.defaultItemLimit` | Specifies the default number of items to show in a view list. Use 0 to specify no limit | +| `gitlens.views.stashFileFormat` | Specifies the format of a stashed file in the views
Available tokens
${directory} - directory name
${file} - file name
${filePath} - formatted file name and path
${path} - full file path | +| `gitlens.views.stashFormat` | Specifies the format of stashed changes in the views
Available tokens
${id} - commit id
${author} - commit author
${message} - commit message
${ago} - relative commit date (e.g. 1 day ago)
\${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)
\${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`
${authorAgo} - commit author, relative commit date
${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`
See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting | +| `gitlens.views.statusFileFormat` | Specifies the format of the status of a working or committed file in the views
Available tokens
${directory} - directory name
${file} - file name
${filePath} - formatted file name and path
${path} - full file path
\${working} - optional indicator if the file is uncommitted | ### Code Lens Settings diff --git a/package.json b/package.json index 410b9de..070b031 100644 --- a/package.json +++ b/package.json @@ -1116,19 +1116,69 @@ "gitlens.views.avatars": { "type": "boolean", "default": true, - "description": "Specifies whether to show avatar images instead of commit (or status) icons in the `Repositories` and `Results` views", + "description": "Specifies whether to show avatar images instead of commit (or status) icons in the views", "scope": "window" }, "gitlens.views.commitFileFormat": { "type": "string", "default": "${filePath}", - "description": "Specifies the format of a committed file in the `Repositories` and `Results` views\nAvailable tokens\n ${directory} - directory name\n ${file} - file name\n ${filePath} - formatted file name and path\n ${path} - full file path", + "description": "Specifies the format of a committed file in the views\nAvailable tokens\n ${directory} - directory name\n ${file} - file name\n ${filePath} - formatted file name and path\n ${path} - full file path", "scope": "window" }, "gitlens.views.commitFormat": { "type": "string", "default": "${message} • ${authorAgoOrDate}${ • changes}${ (id)}", - "description": "Specifies the format of committed changes in the `Repositories` and `Results` views\nAvailable tokens\n ${id} - commit id\n ${author} - commit author\n ${message} - commit message\n ${ago} - relative commit date (e.g. 1 day ago)\n ${date} - formatted commit date (format specified by `gitlens.defaultDateFormat`)\\n ${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`\n ${authorAgo} - commit author, relative commit date\n ${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`\nSee https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting", + "description": "Specifies the format of committed changes in the views\nAvailable tokens\n ${id} - commit id\n ${author} - commit author\n ${message} - commit message\n ${ago} - relative commit date (e.g. 1 day ago)\n ${date} - formatted commit date (format specified by `gitlens.defaultDateFormat`)\\n ${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`\n ${authorAgo} - commit author, relative commit date\n ${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`\nSee https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting", + "scope": "window" + }, + "gitlens.views.compare.enabled": { + "type": "boolean", + "default": true, + "description": "Specifies whether to show the `Compare` view", + "scope": "window" + }, + "gitlens.views.compare.files.compact": { + "type": "boolean", + "default": true, + "description": "Specifies whether to compact (flatten) unnecessary file nesting in the `Compare` view\nOnly applies when `#gitlens.views.compare.files.layout#` is set to `tree` or `auto`", + "scope": "window" + }, + "gitlens.views.compare.files.layout": { + "type": "string", + "default": "auto", + "enum": [ + "auto", + "list", + "tree" + ], + "enumDescriptions": [ + "Automatically switches between displaying files as a `tree` or `list` based on the `#gitlens.views.compare.files.threshold#` value and the number of files at each nesting level", + "Displays files as a list", + "Displays files as a tree" + ], + "description": "Specifies how the `Compare` view will display files", + "scope": "window" + }, + "gitlens.views.compare.files.threshold": { + "type": "number", + "default": 5, + "description": "Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the `Compare` view\nOnly applies when `#gitlens.views.compare.files.layout#` is set to `auto`", + "scope": "window" + }, + "gitlens.views.compare.location": { + "type": "string", + "default": "gitlens", + "enum": [ + "gitlens", + "explorer", + "scm" + ], + "enumDescriptions": [ + "Adds to the GitLens side bar", + "Adds to the Explorer side bar", + "Adds to the Source Control side bar" + ], + "description": "Specifies where to show the `Compare` view", "scope": "window" }, "gitlens.views.defaultItemLimit": { @@ -1158,9 +1208,9 @@ "scm" ], "enumDescriptions": [ - "Adds to the GitLens view", - "Adds to the Explorer view", - "Adds to the Source Control view" + "Adds to the GitLens side bar", + "Adds to the Explorer side bar", + "Adds to the Source Control side bar" ], "description": "Specifies where to show the `File History` view", "scope": "window" @@ -1186,9 +1236,9 @@ "scm" ], "enumDescriptions": [ - "Adds to the GitLens view", - "Adds to the Explorer view", - "Adds to the Source Control view" + "Adds to the GitLens side bar", + "Adds to the Explorer side bar", + "Adds to the Source Control side bar" ], "description": "Specifies where to show the `Line History` view", "scope": "window" @@ -1268,9 +1318,9 @@ "scm" ], "enumDescriptions": [ - "Adds to the GitLens view", - "Adds to the Explorer view", - "Adds to the Source Control view" + "Adds to the GitLens side bar", + "Adds to the Explorer side bar", + "Adds to the Source Control side bar" ], "description": "Specifies where to show the `Repositories` view", "scope": "window" @@ -1281,56 +1331,6 @@ "description": "Specifies whether to show the tracking branch when displaying local branches in the `Repositories` view", "scope": "window" }, - "gitlens.views.results.enabled": { - "type": "boolean", - "default": true, - "description": "Specifies whether to show the `Results` view", - "scope": "window" - }, - "gitlens.views.results.files.compact": { - "type": "boolean", - "default": true, - "description": "Specifies whether to compact (flatten) unnecessary file nesting in the `Results` view\nOnly applies when `#gitlens.views.results.files.layout#` is set to `tree` or `auto`", - "scope": "window" - }, - "gitlens.views.results.files.layout": { - "type": "string", - "default": "auto", - "enum": [ - "auto", - "list", - "tree" - ], - "enumDescriptions": [ - "Automatically switches between displaying files as a `tree` or `list` based on the `#gitlens.views.results.files.threshold#` value and the number of files at each nesting level", - "Displays files as a list", - "Displays files as a tree" - ], - "description": "Specifies how the `Results` view will display files", - "scope": "window" - }, - "gitlens.views.results.files.threshold": { - "type": "number", - "default": 5, - "description": "Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the `Results` view\nOnly applies when `#gitlens.views.results.files.layout#` is set to `auto`", - "scope": "window" - }, - "gitlens.views.results.location": { - "type": "string", - "default": "gitlens", - "enum": [ - "gitlens", - "explorer", - "scm" - ], - "enumDescriptions": [ - "Adds to the GitLens view", - "Adds to the Explorer view", - "Adds to the Source Control view" - ], - "description": "Specifies where to show the `Results` view", - "scope": "window" - }, "gitlens.views.search.enabled": { "type": "boolean", "default": true, @@ -1356,7 +1356,7 @@ "Displays files as a list", "Displays files as a tree" ], - "description": "Specifies how the `Results` view will display files", + "description": "Specifies how the `Search Commits` view will display files", "scope": "window" }, "gitlens.views.search.files.threshold": { @@ -1374,9 +1374,9 @@ "scm" ], "enumDescriptions": [ - "Adds to the GitLens view", - "Adds to the Explorer view", - "Adds to the Source Control view" + "Adds to the GitLens side bar", + "Adds to the Explorer side bar", + "Adds to the Source Control side bar" ], "description": "Specifies where to show the `Search Commits` view", "scope": "window" @@ -1384,19 +1384,19 @@ "gitlens.views.stashFileFormat": { "type": "string", "default": "${filePath}", - "description": "Specifies the format of a stashed file in the `Repositories` and `Results` views\nAvailable tokens\n ${directory} - directory name\n ${file} - file name\n ${filePath} - formatted file name and path\n ${path} - full file path", + "description": "Specifies the format of a stashed file in the views\nAvailable tokens\n ${directory} - directory name\n ${file} - file name\n ${filePath} - formatted file name and path\n ${path} - full file path", "scope": "window" }, "gitlens.views.stashFormat": { "type": "string", "default": "${message}", - "description": "Specifies the format of stashed changes in the `Repositories` and `Results` views\nAvailable tokens\n ${id} - commit id\n ${author} - commit author\n ${message} - commit message\n ${ago} - relative commit date (e.g. 1 day ago)\n ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)\n ${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`\n ${authorAgo} - commit author, relative commit date\n ${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`\nSee https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting", + "description": "Specifies the format of stashed changes in the views\nAvailable tokens\n ${id} - commit id\n ${author} - commit author\n ${message} - commit message\n ${ago} - relative commit date (e.g. 1 day ago)\n ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)\n ${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`\n ${authorAgo} - commit author, relative commit date\n ${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`\nSee https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting", "scope": "window" }, "gitlens.views.statusFileFormat": { "type": "string", "default": "${working }${filePath}", - "description": "Specifies the format of the status of a working or committed file in the `Repositories` view\nAvailable tokens\n ${directory} - directory name\n ${file} - file name\n ${filePath} - formatted file name and path\n ${path} - full file path\n ${working} - optional indicator if the file is uncommitted", + "description": "Specifies the format of the status of a working or committed file in the views\nAvailable tokens\n ${directory} - directory name\n ${file} - file name\n ${filePath} - formatted file name and path\n ${path} - full file path\n ${working} - optional indicator if the file is uncommitted", "scope": "window" }, "gitlens.advanced.blame.customArguments": { @@ -1584,6 +1584,11 @@ "category": "GitLens" }, { + "command": "gitlens.showCompareView", + "title": "Show Compare View", + "category": "GitLens" + }, + { "command": "gitlens.showFileHistoryView", "title": "Show File History View", "category": "GitLens" @@ -1599,11 +1604,6 @@ "category": "GitLens" }, { - "command": "gitlens.showResultsView", - "title": "Show Results View", - "category": "GitLens" - }, - { "command": "gitlens.showSearchView", "title": "Show Search Commits View", "category": "GitLens" @@ -2369,7 +2369,7 @@ "category": "GitLens" }, { - "command": "gitlens.views.results.clear", + "command": "gitlens.views.compare.clear", "title": "Clear Results", "category": "GitLens", "icon": { @@ -2378,7 +2378,7 @@ } }, { - "command": "gitlens.views.results.refresh", + "command": "gitlens.views.compare.refresh", "title": "Refresh", "category": "GitLens", "icon": { @@ -2387,22 +2387,22 @@ } }, { - "command": "gitlens.views.results.setFilesLayoutToAuto", + "command": "gitlens.views.compare.setFilesLayoutToAuto", "title": "Automatic Layout", "category": "GitLens" }, { - "command": "gitlens.views.results.setFilesLayoutToList", + "command": "gitlens.views.compare.setFilesLayoutToList", "title": "List Layout", "category": "GitLens" }, { - "command": "gitlens.views.results.setFilesLayoutToTree", + "command": "gitlens.views.compare.setFilesLayoutToTree", "title": "Tree Layout", "category": "GitLens" }, { - "command": "gitlens.views.results.setKeepResultsToOn", + "command": "gitlens.views.compare.setKeepResultsToOn", "title": "Keep Results", "category": "GitLens", "icon": { @@ -2411,7 +2411,7 @@ } }, { - "command": "gitlens.views.results.setKeepResultsToOff", + "command": "gitlens.views.compare.setKeepResultsToOff", "title": "Keep Results", "category": "GitLens", "icon": { @@ -2420,7 +2420,7 @@ } }, { - "command": "gitlens.views.results.swapComparision", + "command": "gitlens.views.compare.swapComparision", "title": "Swap Comparision", "category": "GitLens", "icon": { @@ -2497,7 +2497,7 @@ "menus": { "commandPalette": [ { - "command": "gitlens.showRepositoriesView", + "command": "gitlens.showCompareView", "when": "gitlens:enabled" }, { @@ -2509,7 +2509,11 @@ "when": "gitlens:enabled" }, { - "command": "gitlens.showResultsView", + "command": "gitlens.showRepositoriesView", + "when": "gitlens:enabled" + }, + { + "command": "gitlens.showSearchView", "when": "gitlens:enabled" }, { @@ -2977,35 +2981,35 @@ "when": "false" }, { - "command": "gitlens.views.results.clear", + "command": "gitlens.views.compare.clear", "when": "false" }, { - "command": "gitlens.views.results.refresh", + "command": "gitlens.views.compare.refresh", "when": "false" }, { - "command": "gitlens.views.results.setFilesLayoutToAuto", + "command": "gitlens.views.compare.setFilesLayoutToAuto", "when": "false" }, { - "command": "gitlens.views.results.setFilesLayoutToList", + "command": "gitlens.views.compare.setFilesLayoutToList", "when": "false" }, { - "command": "gitlens.views.results.setFilesLayoutToTree", + "command": "gitlens.views.compare.setFilesLayoutToTree", "when": "false" }, { - "command": "gitlens.views.results.setKeepResultsToOn", + "command": "gitlens.views.compare.setKeepResultsToOn", "when": "false" }, { - "command": "gitlens.views.results.setKeepResultsToOff", + "command": "gitlens.views.compare.setKeepResultsToOff", "when": "false" }, { - "command": "gitlens.views.results.swapComparision", + "command": "gitlens.views.compare.swapComparision", "when": "false" }, { @@ -3382,38 +3386,38 @@ "group": "1_gitlens" }, { - "command": "gitlens.views.results.clear", - "when": "view =~ /^gitlens\\.views\\.results:/", + "command": "gitlens.views.compare.clear", + "when": "view =~ /^gitlens\\.views\\.compare:/", "group": "navigation@2" }, { - "command": "gitlens.views.results.setKeepResultsToOn", - "when": "view =~ /^gitlens\\.views\\.results:/ && !gitlens:views:results:keepResults", + "command": "gitlens.views.compare.setKeepResultsToOn", + "when": "view =~ /^gitlens\\.views\\.compare:/ && !gitlens:views:compare:keepResults", "group": "navigation@3" }, { - "command": "gitlens.views.results.setKeepResultsToOff", - "when": "view =~ /^gitlens\\.views\\.results:/ && gitlens:views:results:keepResults", + "command": "gitlens.views.compare.setKeepResultsToOff", + "when": "view =~ /^gitlens\\.views\\.compare:/ && gitlens:views:compare:keepResults", "group": "navigation@3" }, { - "command": "gitlens.views.results.refresh", - "when": "view =~ /^gitlens\\.views\\.results:/", + "command": "gitlens.views.compare.refresh", + "when": "view =~ /^gitlens\\.views\\.compare:/", "group": "navigation@99" }, { - "command": "gitlens.views.results.setFilesLayoutToAuto", - "when": "view =~ /^gitlens\\.views\\.results:/", + "command": "gitlens.views.compare.setFilesLayoutToAuto", + "when": "view =~ /^gitlens\\.views\\.compare:/", "group": "1_gitlens" }, { - "command": "gitlens.views.results.setFilesLayoutToList", - "when": "view =~ /^gitlens\\.views\\.results:/", + "command": "gitlens.views.compare.setFilesLayoutToList", + "when": "view =~ /^gitlens\\.views\\.compare:/", "group": "1_gitlens" }, { - "command": "gitlens.views.results.setFilesLayoutToTree", - "when": "view =~ /^gitlens\\.views\\.results:/", + "command": "gitlens.views.compare.setFilesLayoutToTree", + "when": "view =~ /^gitlens\\.views\\.compare:/", "group": "1_gitlens" }, { @@ -3899,28 +3903,28 @@ "group": "8_gitlens@1" }, { - "command": "gitlens.views.results.swapComparision", - "when": "viewItem == gitlens:results:comparison", + "command": "gitlens.views.compare.swapComparision", + "when": "viewItem == gitlens:compare:results", "group": "inline@1" }, { "command": "gitlens.views.dismissNode", - "when": "viewItem =~ /gitlens:(compare:picker:ref|results|search)\\b(?!:(commits|files))/", + "when": "viewItem =~ /gitlens:(compare:picker:ref|compare|search)\\b(?!:(commits|files))/", "group": "inline@2" }, { "command": "gitlens.views.dismissNode", - "when": "viewItem =~ /gitlens:(compare:picker:ref|results|search)\\b(?!:(commits|files))/", + "when": "viewItem =~ /gitlens:(compare:picker:ref|compare|search)\\b(?!:(commits|files))/", "group": "1_gitlens@1" }, { - "command": "gitlens.views.results.swapComparision", - "when": "viewItem == gitlens:results:comparison", + "command": "gitlens.views.compare.swapComparision", + "when": "viewItem == gitlens:compare:results", "group": "2_gitlens@1" }, { "command": "gitlens.views.openDirectoryDiff", - "when": "viewItem == gitlens:results:comparison", + "when": "viewItem == gitlens:compare:results", "group": "7_gitlens@1" }, { @@ -4184,9 +4188,9 @@ "when": "config.gitlens.views.lineHistory.enabled && config.gitlens.views.lineHistory.location == gitlens" }, { - "id": "gitlens.views.results:gitlens", + "id": "gitlens.views.compare:gitlens", "name": "Compare", - "when": "gitlens:enabled && config.gitlens.views.results.enabled && config.gitlens.views.results.location == gitlens" + "when": "gitlens:enabled && config.gitlens.views.compare.enabled && config.gitlens.views.compare.location == gitlens" }, { "id": "gitlens.views.search:gitlens", @@ -4211,9 +4215,9 @@ "when": "gitlens:enabled && config.gitlens.views.lineHistory.enabled && config.gitlens.views.lineHistory.location == explorer" }, { - "id": "gitlens.views.results:explorer", + "id": "gitlens.views.compare:explorer", "name": "GitLens: Compare", - "when": "gitlens:enabled && config.gitlens.views.results.enabled && config.gitlens.views.results.location == explorer" + "when": "gitlens:enabled && config.gitlens.views.compare.enabled && config.gitlens.views.compare.location == explorer" }, { "id": "gitlens.views.search:explorer", @@ -4238,9 +4242,9 @@ "when": "gitlens:enabled && config.gitlens.views.lineHistory.enabled && config.gitlens.views.lineHistory.location == scm" }, { - "id": "gitlens.views.results:scm", + "id": "gitlens.views.compare:scm", "name": "GitLens: Compare", - "when": "gitlens:enabled && config.gitlens.views.results.enabled && config.gitlens.views.results.location == scm" + "when": "gitlens:enabled && config.gitlens.views.compare.enabled && config.gitlens.views.compare.location == scm" }, { "id": "gitlens.views.search:scm", diff --git a/src/commands/common.ts b/src/commands/common.ts index d3cea3e..5b15c70 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -58,6 +58,7 @@ export enum Commands { ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings', ShowCommitInView = 'gitlens.showCommitInView', ShowCommitSearch = 'gitlens.showCommitSearch', + ShowCompareView = 'gitlens.showCompareView', ShowFileHistoryView = 'gitlens.showFileHistoryView', ShowFileHistoryInView = 'gitlens.showFileHistoryInView', ShowLineHistoryView = 'gitlens.showLineHistoryView', @@ -71,7 +72,6 @@ export enum Commands { ShowQuickRevisionDetails = 'gitlens.showQuickRevisionDetails', ShowQuickStashList = 'gitlens.showQuickStashList', ShowRepositoriesView = 'gitlens.showRepositoriesView', - ShowResultsView = 'gitlens.showResultsView', ShowSearchView = 'gitlens.showSearchView', ShowSettingsPage = 'gitlens.showSettingsPage', ShowWelcomePage = 'gitlens.showWelcomePage', diff --git a/src/commands/diffBranchWithBranch.ts b/src/commands/diffBranchWithBranch.ts index 9557cad..2e10c39 100644 --- a/src/commands/diffBranchWithBranch.ts +++ b/src/commands/diffBranchWithBranch.ts @@ -75,7 +75,7 @@ export class DiffBranchWithBranchCommand extends ActiveEditorCommand { if (args.ref1 === undefined) return undefined; } - await Container.resultsView.compare(repoPath, args.ref1, args.ref2); + await Container.compareView.compare(repoPath, args.ref1, args.ref2); return undefined; } diff --git a/src/commands/diffDirectory.ts b/src/commands/diffDirectory.ts index d7b225e..7a43ee6 100644 --- a/src/commands/diffDirectory.ts +++ b/src/commands/diffDirectory.ts @@ -1,11 +1,11 @@ 'use strict'; -import { CancellationTokenSource, commands, TextEditor, Uri, window } from 'vscode'; +import { commands, TextEditor, Uri, window } from 'vscode'; import { BuiltInCommands, GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; import { Messages } from '../messages'; import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks'; -import { ResultsComparisonNode } from '../views/nodes'; +import { CompareResultsNode } from '../views/nodes'; import { ActiveEditorCommand, command, @@ -30,7 +30,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand { protected async preExecute(context: CommandContext, args: DiffDirectoryCommandArgs = {}): Promise { switch (context.command) { case Commands.ViewsOpenDirectoryDiff: - if (context.type === 'viewItem' && context.node instanceof ResultsComparisonNode) { + if (context.type === 'viewItem' && context.node instanceof CompareResultsNode) { args.ref1 = context.node.ref1.ref; args.ref2 = context.node.ref2.ref; } diff --git a/src/commands/showCommitSearch.ts b/src/commands/showCommitSearch.ts index 110a07c..0148651 100644 --- a/src/commands/showCommitSearch.ts +++ b/src/commands/showCommitSearch.ts @@ -192,7 +192,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { [uri, { ...args, maxCount: 0, goBackCommand: goBackCommand }] ) : undefined, - showInResultsCommand: + showInViewCommand: log !== undefined ? new ShowCommitSearchResultsInViewQuickPickItem(log, { label: searchLabel! }) : undefined diff --git a/src/commands/showView.ts b/src/commands/showView.ts index 6923f2f..74f24b2 100644 --- a/src/commands/showView.ts +++ b/src/commands/showView.ts @@ -6,10 +6,10 @@ import { command, Command, CommandContext, Commands } from './common'; export class ShowViewCommand extends Command { constructor() { super([ - Commands.ShowRepositoriesView, + Commands.ShowCompareView, Commands.ShowFileHistoryView, Commands.ShowLineHistoryView, - Commands.ShowResultsView, + Commands.ShowRepositoriesView, Commands.ShowSearchView ]); } @@ -20,14 +20,14 @@ export class ShowViewCommand extends Command { execute(command: Commands) { switch (command) { - case Commands.ShowRepositoriesView: - return Container.repositoriesView.show(); + case Commands.ShowCompareView: + return Container.compareView.show(); case Commands.ShowFileHistoryView: return Container.fileHistoryView.show(); case Commands.ShowLineHistoryView: return Container.lineHistoryView.show(); - case Commands.ShowResultsView: - return Container.resultsView.show(); + case Commands.ShowRepositoriesView: + return Container.repositoriesView.show(); case Commands.ShowSearchView: return Container.searchView.show(); } diff --git a/src/configuration.ts b/src/configuration.ts index 2d40a94..2ac3223 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -44,10 +44,11 @@ export class Configuration { `gitlens.${this.name('currentLine').value}`, `gitlens.${this.name('hovers').value}`, `gitlens.${this.name('statusBar').value}`, + `gitlens.${this.name('views')('compare').value}`, `gitlens.${this.name('views')('fileHistory').value}`, `gitlens.${this.name('views')('lineHistory').value}`, `gitlens.${this.name('views')('repositories').value}`, - `gitlens.${this.name('views')('results').value}` + `gitlens.${this.name('views')('search').value}` ]; } diff --git a/src/constants.ts b/src/constants.ts index 8496816..5fc5b33 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -35,10 +35,10 @@ export enum CommandContext { Key = 'gitlens:key', ViewsCanCompare = 'gitlens:views:canCompare', ViewsCanCompareFile = 'gitlens:views:canCompare:file', + ViewsCompareKeepResults = 'gitlens:views:compare:keepResults', ViewsFileHistoryEditorFollowing = 'gitlens:views:fileHistory:editorFollowing', ViewsLineHistoryEditorFollowing = 'gitlens:views:lineHistory:editorFollowing', ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh', - ViewsResultsKeepResults = 'gitlens:views:results:keepResults', ViewsSearchKeepResults = 'gitlens:views:search:keepResults' } @@ -126,7 +126,7 @@ export const ImageMimetypes: { [key: string]: string } = { }; export enum WorkspaceState { + ViewsCompareKeepResults = 'gitlens:views:compare:keepResults', ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh', - ViewsResultsKeepResults = 'gitlens:views:results:keepResults', ViewsSearchKeepResults = 'gitlens:views:search:keepResults' } diff --git a/src/container.ts b/src/container.ts index 26c1384..14a9a92 100644 --- a/src/container.ts +++ b/src/container.ts @@ -11,10 +11,10 @@ import { Keyboard } from './keyboard'; import { StatusBarController } from './statusbar/statusBarController'; import { GitDocumentTracker } from './trackers/gitDocumentTracker'; import { GitLineTracker } from './trackers/gitLineTracker'; +import { CompareView } from './views/compareView'; import { FileHistoryView } from './views/fileHistoryView'; import { LineHistoryView } from './views/lineHistoryView'; import { RepositoriesView } from './views/repositoriesView'; -import { ResultsView } from './views/resultsView'; import { SearchView } from './views/searchView'; import { ViewCommands } from './views/viewCommands'; import { SettingsEditor } from './webviews/settingsEditor'; @@ -41,15 +41,15 @@ export class Container { context.subscriptions.push((this._settingsEditor = new SettingsEditor())); context.subscriptions.push((this._welcomeEditor = new WelcomeEditor())); - if (config.views.repositories.enabled) { - context.subscriptions.push((this._repositoriesView = new RepositoriesView())); + if (config.views.compare.enabled) { + context.subscriptions.push((this._compareView = new CompareView())); } else { let disposable: Disposable; disposable = configuration.onDidChange(e => { - if (configuration.changed(e, configuration.name('views')('repositories')('enabled').value)) { + if (configuration.changed(e, configuration.name('views')('compare')('enabled').value)) { disposable.dispose(); - context.subscriptions.push((this._repositoriesView = new RepositoriesView())); + context.subscriptions.push((this._compareView = new CompareView())); } }); } @@ -80,15 +80,15 @@ export class Container { }); } - if (config.views.results.enabled) { - context.subscriptions.push((this._resultsView = new ResultsView())); + if (config.views.repositories.enabled) { + context.subscriptions.push((this._repositoriesView = new RepositoriesView())); } else { let disposable: Disposable; disposable = configuration.onDidChange(e => { - if (configuration.changed(e, configuration.name('views')('results')('enabled').value)) { + if (configuration.changed(e, configuration.name('views')('repositories')('enabled').value)) { disposable.dispose(); - context.subscriptions.push((this._resultsView = new ResultsView())); + context.subscriptions.push((this._repositoriesView = new RepositoriesView())); } }); } @@ -114,6 +114,15 @@ export class Container { return this._codeLensController; } + private static _compareView: CompareView | undefined; + static get compareView() { + if (this._compareView === undefined) { + this._context.subscriptions.push((this._compareView = new CompareView())); + } + + return this._compareView; + } + private static _config: Config | undefined; static get config() { if (this._config === undefined) { @@ -146,11 +155,6 @@ export class Container { return this._git; } - private static _repositoriesView: RepositoriesView | undefined; - static get repositoriesView(): RepositoriesView { - return this._repositoriesView!; - } - private static _keyboard: Keyboard; static get keyboard() { return this._keyboard; @@ -180,13 +184,9 @@ export class Container { return this._lineTracker; } - private static _resultsView: ResultsView | undefined; - static get resultsView() { - if (this._resultsView === undefined) { - this._context.subscriptions.push((this._resultsView = new ResultsView())); - } - - return this._resultsView; + private static _repositoriesView: RepositoriesView | undefined; + static get repositoriesView(): RepositoriesView { + return this._repositoriesView!; } private static _searchView: SearchView | undefined; @@ -239,15 +239,22 @@ export class Container { if (mode.codeLens != null) { config.codeLens.enabled = mode.codeLens; } + if (mode.currentLine != null) { config.currentLine.enabled = mode.currentLine; } + if (mode.hovers != null) { config.hovers.enabled = mode.hovers; } + if (mode.statusBar != null) { config.statusBar.enabled = mode.statusBar; } + + if (mode.views != null) { + config.views.compare.enabled = mode.views; + } if (mode.views != null) { config.views.fileHistory.enabled = mode.views; } @@ -257,9 +264,9 @@ export class Container { if (mode.views != null) { config.views.repositories.enabled = mode.views; } - // if (mode.views != null) { - // config.views.results.enabled = mode.views; - // } + if (mode.views != null) { + config.views.search.enabled = mode.views; + } return config; } diff --git a/src/extension.ts b/src/extension.ts index ff9d86d..913a769 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -152,6 +152,40 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin configuration.name('views')('lineHistory')('location').value ); + await configuration.migrate( + 'resultsExplorer.files.compact', + configuration.name('views')('compare')('files')('compact').value + ); + await configuration.migrate( + 'resultsExplorer.files.layout', + configuration.name('views')('compare')('files')('layout').value + ); + await configuration.migrate( + 'resultsExplorer.files.threshold', + configuration.name('views')('compare')('files')('threshold').value + ); + await configuration.migrate( + 'resultsExplorer.location', + configuration.name('views')('compare')('location').value + ); + + await configuration.migrate( + 'resultsExplorer.files.compact', + configuration.name('views')('search')('files')('compact').value + ); + await configuration.migrate( + 'resultsExplorer.files.layout', + configuration.name('views')('search')('files')('layout').value + ); + await configuration.migrate( + 'resultsExplorer.files.threshold', + configuration.name('views')('search')('files')('threshold').value + ); + await configuration.migrate( + 'resultsExplorer.location', + configuration.name('views')('search')('location').value + ); + await configuration.migrate('explorers.avatars', configuration.name('views')('avatars').value); await configuration.migrate( 'explorers.commitFileFormat', diff --git a/src/quickpicks/commitsQuickPick.ts b/src/quickpicks/commitsQuickPick.ts index 5c09925..35065dd 100644 --- a/src/quickpicks/commitsQuickPick.ts +++ b/src/quickpicks/commitsQuickPick.ts @@ -28,15 +28,15 @@ export class CommitsQuickPick { options: { goBackCommand?: CommandQuickPickItem; showAllCommand?: CommandQuickPickItem; - showInResultsCommand?: CommandQuickPickItem; + showInViewCommand?: CommandQuickPickItem; } ): Promise { const items = ((log && [...Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))]) || [ new MessageQuickPickItem('No results found') ]) as (CommitQuickPickItem | CommandQuickPickItem)[]; - if (options.showInResultsCommand !== undefined) { - items.splice(0, 0, options.showInResultsCommand); + if (options.showInViewCommand !== undefined) { + items.splice(0, 0, options.showInViewCommand); } if (options.showAllCommand !== undefined) { diff --git a/src/ui/config.ts b/src/ui/config.ts index 0d29893..fa8ca8c 100644 --- a/src/ui/config.ts +++ b/src/ui/config.ts @@ -151,11 +151,11 @@ export interface ViewsConfig { }; commitFileFormat: string; commitFormat: string; + compare: CompareViewConfig; // dateFormat: string | null; defaultItemLimit: number; lineHistory: LineHistoryViewConfig; repositories: RepositoriesViewConfig; - results: ResultsViewConfig; search: SearchViewConfig; stashFileFormat: string; stashFormat: string; @@ -233,7 +233,7 @@ export interface RepositoriesViewConfig { showTrackingBranch: boolean; } -export interface ResultsViewConfig { +export interface CompareViewConfig { enabled: boolean; files: ViewsFilesConfig; location: 'explorer' | 'gitlens' | 'scm'; diff --git a/src/ui/settings/index.html b/src/ui/settings/index.html index 1fb328c..9489060 100644 --- a/src/ui/settings/index.html +++ b/src/ui/settings/index.html @@ -314,9 +314,9 @@ @@ -424,9 +424,9 @@ @@ -470,9 +470,9 @@ @@ -492,32 +492,31 @@ -
+
-

Results view - +

Compare view +

- Adds an on-demand Results view to navigate and explore commits, histories, and - searches, or visualize comparisons between branches, tags, commits, and more + Adds a Compare view to visualize comparisons between branches, tags, commits, and more

- - + + +
- - - - + + +

@@ -555,7 +554,74 @@ User Settings - and search for gitlens.views.results or gitlens.views + and search for gitlens.views.compare or gitlens.views +

+
+
+ +
+
+

Search Commits view + + + +

+

+ Adds a Search Commits view to search and explore commit histories by message, author, files, id, etc +

+
+
+
+
+ + +
+ + + + + + + +
+ +
+ + + + +
+

+ + For more advanced customizations open + + User Settings + + and search for gitlens.views.search or gitlens.views

@@ -1618,8 +1684,13 @@
  • - - Results view + + Compare view + +
  • +
  • + + Search Commits view
  • diff --git a/src/ui/welcome/index.html b/src/ui/welcome/index.html index 6c71cae..e803094 100644 --- a/src/ui/welcome/index.html +++ b/src/ui/welcome/index.html @@ -118,11 +118,16 @@ current file
  • - an on-demand - Results view + a + Compare view - to navigate and explore commits, histories, and searches, or visualize comparisons - between branches, tags, commits, and more + to visualize comparisons between branches, tags, commits, and more +
  • +
  • + a + Search Commits view + + to search and explore commit histories by message, author, files, id, etc
  • diff --git a/src/views/compareView.ts b/src/views/compareView.ts new file mode 100644 index 0000000..532da65 --- /dev/null +++ b/src/views/compareView.ts @@ -0,0 +1,135 @@ +'use strict'; +import { commands, ConfigurationChangeEvent } from 'vscode'; +import { CompareViewConfig, configuration, ViewFilesLayout, ViewsConfig } from '../configuration'; +import { CommandContext, setCommandContext, WorkspaceState } from '../constants'; +import { Container } from '../container'; +import { CompareNode, CompareResultsNode, NamedRef, ViewNode } from './nodes'; +import { RefreshReason, ViewBase } from './viewBase'; + +export class CompareView extends ViewBase { + constructor() { + super('gitlens.views.compare'); + + setCommandContext(CommandContext.ViewsCompareKeepResults, this.keepResults); + } + + getRoot() { + return new CompareNode(this); + } + + protected get location(): string { + return this.config.location; + } + + protected registerCommands() { + void Container.viewCommands; + commands.registerCommand(this.getQualifiedCommand('clear'), () => this.clear(), this); + commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this); + commands.registerCommand( + this.getQualifiedCommand('setFilesLayoutToAuto'), + () => this.setFilesLayout(ViewFilesLayout.Auto), + this + ); + commands.registerCommand( + this.getQualifiedCommand('setFilesLayoutToList'), + () => this.setFilesLayout(ViewFilesLayout.List), + this + ); + commands.registerCommand( + this.getQualifiedCommand('setFilesLayoutToTree'), + () => this.setFilesLayout(ViewFilesLayout.Tree), + this + ); + commands.registerCommand(this.getQualifiedCommand('setKeepResultsToOn'), () => this.setKeepResults(true), this); + commands.registerCommand( + this.getQualifiedCommand('setKeepResultsToOff'), + () => this.setKeepResults(false), + this + ); + commands.registerCommand(this.getQualifiedCommand('swapComparision'), this.swapComparision, this); + + commands.registerCommand(this.getQualifiedCommand('selectForCompare'), this.selectForCompare, this); + commands.registerCommand(this.getQualifiedCommand('compareWithSelected'), this.compareWithSelected, this); + } + + protected onConfigurationChanged(e: ConfigurationChangeEvent) { + if ( + !configuration.changed(e, configuration.name('views')('compare').value) && + !configuration.changed(e, configuration.name('views').value) && + !configuration.changed(e, configuration.name('defaultGravatarsStyle').value) + ) { + return; + } + + if (configuration.changed(e, configuration.name('views')('compare')('location').value)) { + this.initialize(this.config.location /*, { showCollapseAll: true } */); + } + + if (!configuration.initializing(e) && this._root !== undefined) { + void this.refresh(RefreshReason.ConfigurationChanged); + } + } + + get config(): ViewsConfig & CompareViewConfig { + return { ...Container.config.views, ...Container.config.views.compare }; + } + + get keepResults(): boolean { + return Container.context.workspaceState.get(WorkspaceState.ViewsCompareKeepResults, false); + } + + clear() { + if (this._root === undefined) return; + + this._root.clear(); + } + + dismissNode(node: ViewNode) { + if (this._root === undefined) return; + + this._root.dismiss(node); + } + + compare(repoPath: string, ref1: string | NamedRef, ref2: string | NamedRef) { + return this.addResults( + new CompareResultsNode( + this, + repoPath, + typeof ref1 === 'string' ? { ref: ref1 } : ref1, + typeof ref2 === 'string' ? { ref: ref2 } : ref2 + ) + ); + } + + compareWithSelected(repoPath?: string, ref?: string | NamedRef) { + const root = this.ensureRoot(); + void root.compareWithSelected(repoPath, ref); + } + + selectForCompare(repoPath?: string, ref?: string | NamedRef) { + const root = this.ensureRoot(); + void root.selectForCompare(repoPath, ref); + } + + private async addResults(results: ViewNode) { + const root = this.ensureRoot(); + root.addOrReplace(results, !this.keepResults); + + setTimeout(() => this._tree!.reveal(results, { select: true }), 250); + } + + private setFilesLayout(layout: ViewFilesLayout) { + return configuration.updateEffective(configuration.name('views')('compare')('files')('layout').value, layout); + } + + private setKeepResults(enabled: boolean) { + Container.context.workspaceState.update(WorkspaceState.ViewsCompareKeepResults, enabled); + setCommandContext(CommandContext.ViewsCompareKeepResults, enabled); + } + + private swapComparision(node: ViewNode) { + if (!(node instanceof CompareResultsNode)) return; + + node.swap(); + } +} diff --git a/src/views/nodes.ts b/src/views/nodes.ts index facbb7d..8446867 100644 --- a/src/views/nodes.ts +++ b/src/views/nodes.ts @@ -13,17 +13,17 @@ export * from './nodes/remoteNode'; export * from './nodes/remotesNode'; export * from './nodes/repositoriesNode'; export * from './nodes/repositoryNode'; +export * from './nodes/compareResultsNode'; +export * from './nodes/compareNode'; export * from './nodes/resultsCommitsNode'; -export * from './nodes/resultsComparisonNode'; -export * from './nodes/resultsNode'; +export * from './nodes/resultsFileNode'; +export * from './nodes/resultsFilesNode'; export * from './nodes/searchNode'; export * from './nodes/stashesNode'; export * from './nodes/stashFileNode'; export * from './nodes/stashNode'; export * from './nodes/statusFileNode'; -export * from './nodes/resultsFileNode'; export * from './nodes/statusFilesNode'; -export * from './nodes/resultsFilesNode'; export * from './nodes/statusUpstreamNode'; export * from './nodes/tagsNode'; export * from './nodes/tagNode'; diff --git a/src/views/nodes/compareNode.ts b/src/views/nodes/compareNode.ts new file mode 100644 index 0000000..e8b3a72 --- /dev/null +++ b/src/views/nodes/compareNode.ts @@ -0,0 +1,171 @@ +'use strict'; +import { TreeItem, TreeItemCollapsibleState } from 'vscode'; +import { getRepoPathOrPrompt } from '../../commands'; +import { CommandContext, GlyphChars, setCommandContext } from '../../constants'; +import { GitService } from '../../git/gitService'; +import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../../quickpicks'; +import { debug, Functions, gate, log } from '../../system'; +import { CompareView } from '../compareView'; +import { MessageNode } from './common'; +import { ComparePickerNode } from './comparePickerNode'; +import { NamedRef, ResourceType, unknownGitUri, ViewNode } from './viewNode'; + +interface RepoRef { + label: string; + repoPath: string; + ref: string | NamedRef; +} + +export class CompareNode extends ViewNode { + private _children: (ViewNode | MessageNode)[] = []; + private _comparePickerNode: ComparePickerNode | undefined; + + constructor(view: CompareView) { + super(unknownGitUri, view); + } + + private _selectedRef: RepoRef | undefined; + get selectedRef(): RepoRef | undefined { + return this._selectedRef; + } + + async getChildren(): Promise { + if (this._children.length === 0) { + // Not really sure why I can't reuse this node -- but if I do the Tree errors out with an id already exists error + this._comparePickerNode = new ComparePickerNode(this.view, this); + this._children = [this._comparePickerNode]; + } + else if ( + this._selectedRef !== undefined && + (this._comparePickerNode === undefined || !this._children.includes(this._comparePickerNode)) + ) { + // Not really sure why I can't reuse this node -- but if I do the Tree errors out with an id already exists error + this._comparePickerNode = new ComparePickerNode(this.view, this); + this._children.splice(0, 0, this._comparePickerNode); + + const node = this._comparePickerNode; + setImmediate(() => this.view.reveal(node, { focus: false, select: true })); + } + + return this._children; + } + + getTreeItem(): TreeItem { + const item = new TreeItem(`Compare`, TreeItemCollapsibleState.Expanded); + item.contextValue = ResourceType.Compare; + return item; + } + + addOrReplace(results: ViewNode, replace: boolean) { + if (this._children.includes(results)) return; + + if (this._children.length !== 0 && replace) { + this._children.length = 0; + this._children.push(results); + } + else { + if (this._comparePickerNode !== undefined) { + const index = this._children.indexOf(this._comparePickerNode); + if (index !== -1) { + this._children.splice(index, 1); + } + } + + this._children.splice(0, 0, results); + } + + this.view.triggerNodeChange(); + } + + @log() + clear() { + this._selectedRef = undefined; + setCommandContext(CommandContext.ViewsCanCompare, false); + + this._children.length = 0; + this.view.triggerNodeChange(); + } + + @log({ + args: { 0: (n: ViewNode) => n.toString() } + }) + dismiss(node: ViewNode) { + this._selectedRef = undefined; + setCommandContext(CommandContext.ViewsCanCompare, false); + + if (this._children.length !== 0) { + const index = this._children.indexOf(node); + if (index === -1) return; + + this._children.splice(index, 1); + } + this.view.triggerNodeChange(); + } + + @gate() + @debug() + async refresh() { + if (this._children.length === 0) return; + + await Promise.all(this._children.map(c => c.refresh()).filter(Functions.isPromise) as Promise[]); + } + + async compareWithSelected(repoPath?: string, ref?: string | NamedRef) { + if (this._selectedRef === undefined) return; + + if (repoPath === undefined) { + repoPath = this._selectedRef.repoPath; + } + else if (repoPath !== this._selectedRef.repoPath) { + // If we don't have a matching repoPath, then start over + this.selectForCompare(repoPath, ref); + return; + } + + if (ref === undefined) { + const pick = await new BranchesAndTagsQuickPick(repoPath).show( + `Compare ${this.getRefName(this._selectedRef.ref)} to${GlyphChars.Ellipsis}` + ); + if (pick === undefined || pick instanceof CommandQuickPickItem) return; + + ref = pick.name; + } + + const ref1 = this._selectedRef; + + this._selectedRef = undefined; + setCommandContext(CommandContext.ViewsCanCompare, false); + + void (await this.view.compare(repoPath, ref1.ref, ref)); + } + + async selectForCompare(repoPath?: string, ref?: string | NamedRef) { + if (repoPath === undefined) { + repoPath = await getRepoPathOrPrompt( + undefined, + `Select branch or tag in which repository${GlyphChars.Ellipsis}` + ); + } + if (repoPath === undefined) return; + + if (ref === undefined) { + const pick = await new BranchesAndTagsQuickPick(repoPath).show( + `Select branch or tag for compare${GlyphChars.Ellipsis}` + ); + if (pick === undefined || pick instanceof CommandQuickPickItem) return; + + ref = pick.name; + } + + this._selectedRef = { label: this.getRefName(ref), repoPath: repoPath, ref: ref }; + setCommandContext(CommandContext.ViewsCanCompare, true); + + await this.view.show(); + + void (await this.triggerChange()); + } + + private getRefName(ref: string | NamedRef) { + return typeof ref === 'string' ? GitService.shortenSha(ref)! : ref.label || GitService.shortenSha(ref.ref)!; + } +} diff --git a/src/views/nodes/comparePickerNode.ts b/src/views/nodes/comparePickerNode.ts index afa519a..559204d 100644 --- a/src/views/nodes/comparePickerNode.ts +++ b/src/views/nodes/comparePickerNode.ts @@ -3,14 +3,14 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import { GlyphChars } from '../../constants'; import { Container } from '../../container'; import { Strings } from '../../system'; -import { ResultsView } from '../resultsView'; -import { ResultsNode } from './resultsNode'; +import { CompareView } from '../compareView'; +import { CompareNode } from './compareNode'; import { ResourceType, unknownGitUri, ViewNode } from './viewNode'; -export class ComparePickerNode extends ViewNode { +export class ComparePickerNode extends ViewNode { constructor( - view: ResultsView, - protected readonly parent: ResultsNode + view: CompareView, + protected readonly parent: CompareNode ) { super(unknownGitUri, view, parent); } @@ -41,7 +41,7 @@ export class ComparePickerNode extends ViewNode { item.tooltip = `Click to select branch or tag for compare${GlyphChars.Ellipsis}`; item.command = { title: `Select branch or tag for compare${GlyphChars.Ellipsis}`, - command: 'gitlens.views.results.selectForCompare' + command: this.view.getQualifiedCommand('selectForCompare') }; } else { @@ -53,7 +53,7 @@ export class ComparePickerNode extends ViewNode { item.tooltip = `Click to compare ${selectedRef.label} to${GlyphChars.Ellipsis}`; item.command = { title: `Compare ${selectedRef.label} with${GlyphChars.Ellipsis}`, - command: 'gitlens.views.results.compareWithSelected' + command: this.view.getQualifiedCommand('compareWithSelected') }; } diff --git a/src/views/nodes/compareResultsNode.ts b/src/views/nodes/compareResultsNode.ts new file mode 100644 index 0000000..3a0cbde --- /dev/null +++ b/src/views/nodes/compareResultsNode.ts @@ -0,0 +1,84 @@ +'use strict'; +import { TreeItem, TreeItemCollapsibleState } from 'vscode'; +import { GlyphChars } from '../../constants'; +import { Container } from '../../container'; +import { GitService, GitUri } from '../../git/gitService'; +import { Strings } from '../../system'; +import { View } from '../viewBase'; +import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode'; +import { ResultsFilesNode } from './resultsFilesNode'; +import { NamedRef, ResourceType, ViewNode } from './viewNode'; + +export class CompareResultsNode extends ViewNode { + constructor( + view: View, + public readonly repoPath: string, + ref1: NamedRef, + ref2: NamedRef + ) { + super(GitUri.fromRepoPath(repoPath), view); + + this._ref1 = ref1; + this._ref2 = ref2; + } + + private _ref1: NamedRef; + get ref1(): NamedRef { + return this._ref1; + } + + private _ref2: NamedRef; + get ref2(): NamedRef { + return this._ref2; + } + + async getChildren(): Promise { + return [ + new ResultsCommitsNode(this.view, this, this.uri.repoPath!, this.getCommitsQuery.bind(this)), + new ResultsFilesNode(this.view, this, this.uri.repoPath!, this._ref1.ref, this._ref2.ref) + ]; + } + + async getTreeItem(): Promise { + let repository = ''; + if ((await Container.git.getRepositoryCount()) > 1) { + const repo = await Container.git.getRepository(this.uri.repoPath!); + repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`; + } + + const item = new TreeItem( + `Comparing ${this._ref1.label || + GitService.shortenSha(this._ref1.ref, { working: 'Working Tree' })} to ${this._ref2.label || + GitService.shortenSha(this._ref2.ref, { working: 'Working Tree' })}${repository}`, + TreeItemCollapsibleState.Expanded + ); + item.contextValue = ResourceType.CompareResults; + + return item; + } + + swap() { + const ref1 = this._ref1; + this._ref1 = this._ref2; + this._ref2 = ref1; + + this.view.triggerNodeChange(this); + } + + private async getCommitsQuery(maxCount: number | undefined): Promise { + const log = await Container.git.getLog(this.uri.repoPath!, { + maxCount: maxCount, + ref: `${this._ref1.ref}...${this._ref2.ref || 'HEAD'}` + }); + + const count = log !== undefined ? log.count : 0; + const truncated = log !== undefined ? log.truncated : false; + + const label = Strings.pluralize('commit', count, { number: truncated ? `${count}+` : undefined, zero: 'No' }); + + return { + label: label, + log: log + }; + } +} diff --git a/src/views/nodes/resultsComparisonNode.ts b/src/views/nodes/resultsComparisonNode.ts deleted file mode 100644 index fd1e4b9..0000000 --- a/src/views/nodes/resultsComparisonNode.ts +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; -import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { GlyphChars } from '../../constants'; -import { Container } from '../../container'; -import { GitService, GitUri } from '../../git/gitService'; -import { Strings } from '../../system'; -import { View } from '../viewBase'; -import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode'; -import { ResultsFilesNode } from './resultsFilesNode'; -import { NamedRef, ResourceType, ViewNode } from './viewNode'; - -export class ResultsComparisonNode extends ViewNode { - constructor( - view: View, - public readonly repoPath: string, - ref1: NamedRef, - ref2: NamedRef - ) { - super(GitUri.fromRepoPath(repoPath), view); - - this._ref1 = ref1; - this._ref2 = ref2; - } - - private _ref1: NamedRef; - get ref1(): NamedRef { - return this._ref1; - } - - private _ref2: NamedRef; - get ref2(): NamedRef { - return this._ref2; - } - - async getChildren(): Promise { - return [ - new ResultsCommitsNode(this.view, this, this.uri.repoPath!, this.getCommitsQuery.bind(this)), - new ResultsFilesNode(this.view, this, this.uri.repoPath!, this._ref1.ref, this._ref2.ref) - ]; - } - - async getTreeItem(): Promise { - let repository = ''; - if ((await Container.git.getRepositoryCount()) > 1) { - const repo = await Container.git.getRepository(this.uri.repoPath!); - repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`; - } - - const item = new TreeItem( - `Comparing ${this._ref1.label || - GitService.shortenSha(this._ref1.ref, { working: 'Working Tree' })} to ${this._ref2.label || - GitService.shortenSha(this._ref2.ref, { working: 'Working Tree' })}${repository}`, - TreeItemCollapsibleState.Expanded - ); - item.contextValue = ResourceType.ComparisonResults; - - return item; - } - - swap() { - const ref1 = this._ref1; - this._ref1 = this._ref2; - this._ref2 = ref1; - - this.view.triggerNodeChange(this); - } - - private async getCommitsQuery(maxCount: number | undefined): Promise { - const log = await Container.git.getLog(this.uri.repoPath!, { - maxCount: maxCount, - ref: `${this._ref1.ref}...${this._ref2.ref || 'HEAD'}` - }); - - const count = log !== undefined ? log.count : 0; - const truncated = log !== undefined ? log.truncated : false; - - const label = Strings.pluralize('commit', count, { number: truncated ? `${count}+` : undefined, zero: 'No' }); - - return { - label: label, - log: log - }; - } -} diff --git a/src/views/nodes/resultsNode.ts b/src/views/nodes/resultsNode.ts deleted file mode 100644 index 147401f..0000000 --- a/src/views/nodes/resultsNode.ts +++ /dev/null @@ -1,169 +0,0 @@ -'use strict'; -import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { getRepoPathOrPrompt } from '../../commands'; -import { CommandContext, GlyphChars, setCommandContext } from '../../constants'; -import { GitService } from '../../git/gitService'; -import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../../quickpicks'; -import { debug, Functions, gate, log } from '../../system'; -import { ResultsView } from '../resultsView'; -import { MessageNode } from './common'; -import { ComparePickerNode } from './comparePickerNode'; -import { NamedRef, ResourceType, unknownGitUri, ViewNode } from './viewNode'; - -interface RepoRef { - label: string; - repoPath: string; - ref: string | NamedRef; -} - -export class ResultsNode extends ViewNode { - private _children: (ViewNode | MessageNode)[] = []; - private _comparePickerNode: ComparePickerNode | undefined; - - constructor(view: ResultsView) { - super(unknownGitUri, view); - } - - private _selectedRef: RepoRef | undefined; - get selectedRef(): RepoRef | undefined { - return this._selectedRef; - } - - async getChildren(): Promise { - if (this._children.length === 0) { - // Not really sure why I can't reuse this node -- but if I do the Tree errors out with an id already exists error - this._comparePickerNode = new ComparePickerNode(this.view, this); - this._children = [this._comparePickerNode]; - } - else if ( - this._selectedRef !== undefined && - (this._comparePickerNode === undefined || !this._children.includes(this._comparePickerNode)) - ) { - // Not really sure why I can't reuse this node -- but if I do the Tree errors out with an id already exists error - this._comparePickerNode = new ComparePickerNode(this.view, this); - this._children.splice(0, 0, this._comparePickerNode); - - const node = this._comparePickerNode; - setImmediate(() => this.view.reveal(node, { focus: false, select: true })); - } - - return this._children; - } - - getTreeItem(): TreeItem { - const item = new TreeItem(`Results`, TreeItemCollapsibleState.Expanded); - item.contextValue = ResourceType.Results; - return item; - } - - addOrReplace(results: ViewNode, replace: boolean) { - if (this._children.includes(results)) return; - - if (this._children.length !== 0 && replace) { - this._children.length = 0; - this._children.push(results); - } - else { - if (this._comparePickerNode !== undefined) { - const index = this._children.indexOf(this._comparePickerNode); - if (index !== -1) { - this._children.splice(index, 1); - } - } - - this._children.splice(0, 0, results); - } - - this.view.triggerNodeChange(); - } - - @log() - clear() { - this._selectedRef = undefined; - setCommandContext(CommandContext.ViewsCanCompare, false); - - this._children.length = 0; - this.view.triggerNodeChange(); - } - - @log({ - args: { 0: (n: ViewNode) => n.toString() } - }) - dismiss(node: ViewNode) { - this._selectedRef = undefined; - setCommandContext(CommandContext.ViewsCanCompare, false); - - if (this._children.length !== 0) { - const index = this._children.indexOf(node); - if (index === -1) return; - - this._children.splice(index, 1); - } - this.view.triggerNodeChange(); - } - - @gate() - @debug() - async refresh() { - if (this._children.length === 0) return; - - await Promise.all(this._children.map(c => c.refresh()).filter(Functions.isPromise) as Promise[]); - } - - async compareWithSelected(repoPath?: string, ref?: string | NamedRef) { - if (this._selectedRef === undefined) return; - - if (repoPath === undefined) { - repoPath = this._selectedRef.repoPath; - } - else if (repoPath !== this._selectedRef.repoPath) { - // If we don't have a matching repoPath, then start over - this.selectForCompare(repoPath, ref); - return; - } - - if (ref === undefined) { - const pick = await new BranchesAndTagsQuickPick(repoPath).show( - `Compare ${this.getRefName(this._selectedRef.ref)} to${GlyphChars.Ellipsis}` - ); - if (pick === undefined || pick instanceof CommandQuickPickItem) return; - - ref = pick.name; - } - - const ref1 = this._selectedRef; - - this._selectedRef = undefined; - setCommandContext(CommandContext.ViewsCanCompare, false); - - void (await this.view.compare(repoPath, ref1.ref, ref)); - } - - async selectForCompare(repoPath?: string, ref?: string | NamedRef) { - if (repoPath === undefined) { - repoPath = await getRepoPathOrPrompt( - undefined, - `Select branch or tag in which repository${GlyphChars.Ellipsis}` - ); - } - if (repoPath === undefined) return; - - if (ref === undefined) { - const pick = await new BranchesAndTagsQuickPick(repoPath).show( - `Select branch or tag for compare${GlyphChars.Ellipsis}` - ); - if (pick === undefined || pick instanceof CommandQuickPickItem) return; - - ref = pick.name; - } - - this._selectedRef = { label: this.getRefName(ref), repoPath: repoPath, ref: ref }; - setCommandContext(CommandContext.ViewsCanCompare, true); - - void (await this.triggerChange()); - } - - private getRefName(ref: string | NamedRef) { - return typeof ref === 'string' ? GitService.shortenSha(ref)! : ref.label || GitService.shortenSha(ref.ref)!; - } -} diff --git a/src/views/nodes/searchNode.ts b/src/views/nodes/searchNode.ts index 3215243..21df7e1 100644 --- a/src/views/nodes/searchNode.ts +++ b/src/views/nodes/searchNode.ts @@ -91,7 +91,7 @@ export class SearchNode extends ViewNode { getTreeItem(): TreeItem { const item = new TreeItem(`Search`, TreeItemCollapsibleState.Expanded); - item.contextValue = ResourceType.Results; + item.contextValue = ResourceType.Search; return item; } diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index 4cee386..5ddbcbf 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -19,9 +19,10 @@ export enum ResourceType { CommitOnCurrentBranch = 'gitlens:commit:current', CommitFile = 'gitlens:file:commit', Commits = 'gitlens:commits', + Compare = 'gitlens:compare', ComparePicker = 'gitlens:compare:picker', ComparePickerWithRef = 'gitlens:compare:picker:ref', - ComparisonResults = 'gitlens:results:comparison', + CompareResults = 'gitlens:compare:results', FileHistory = 'gitlens:history:file', FileStaged = 'gitlens:file:staged', FileStagedAndUnstaged = 'gitlens:file:staged:unstaged', @@ -34,12 +35,11 @@ export enum ResourceType { Remotes = 'gitlens:remotes', Repositories = 'gitlens:repositories', Repository = 'gitlens:repository', - Results = 'gitlens:results', ResultsCommits = 'gitlens:results:commits', ResultsFile = 'gitlens:file:results', ResultsFiles = 'gitlens:results:files', - SearchResults = 'gitlens:results:search', Search = 'gitlens:search', + SearchResults = 'gitlens:search:results', Stash = 'gitlens:stash', StashFile = 'gitlens:file:stash', Stashes = 'gitlens:stashes', diff --git a/src/views/resultsView.ts b/src/views/resultsView.ts deleted file mode 100644 index 3df26c0..0000000 --- a/src/views/resultsView.ts +++ /dev/null @@ -1,135 +0,0 @@ -'use strict'; -import { commands, ConfigurationChangeEvent } from 'vscode'; -import { configuration, ResultsViewConfig, ViewFilesLayout, ViewsConfig } from '../configuration'; -import { CommandContext, setCommandContext, WorkspaceState } from '../constants'; -import { Container } from '../container'; -import { NamedRef, ResultsComparisonNode, ResultsNode, ViewNode } from './nodes'; -import { RefreshReason, ViewBase } from './viewBase'; - -export class ResultsView extends ViewBase { - constructor() { - super('gitlens.views.results'); - - setCommandContext(CommandContext.ViewsResultsKeepResults, this.keepResults); - } - - getRoot() { - return new ResultsNode(this); - } - - protected get location(): string { - return this.config.location; - } - - protected registerCommands() { - void Container.viewCommands; - commands.registerCommand(this.getQualifiedCommand('clear'), () => this.clear(), this); - commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this); - commands.registerCommand( - this.getQualifiedCommand('setFilesLayoutToAuto'), - () => this.setFilesLayout(ViewFilesLayout.Auto), - this - ); - commands.registerCommand( - this.getQualifiedCommand('setFilesLayoutToList'), - () => this.setFilesLayout(ViewFilesLayout.List), - this - ); - commands.registerCommand( - this.getQualifiedCommand('setFilesLayoutToTree'), - () => this.setFilesLayout(ViewFilesLayout.Tree), - this - ); - commands.registerCommand(this.getQualifiedCommand('setKeepResultsToOn'), () => this.setKeepResults(true), this); - commands.registerCommand( - this.getQualifiedCommand('setKeepResultsToOff'), - () => this.setKeepResults(false), - this - ); - commands.registerCommand(this.getQualifiedCommand('swapComparision'), this.swapComparision, this); - - commands.registerCommand(this.getQualifiedCommand('selectForCompare'), this.selectForCompare, this); - commands.registerCommand(this.getQualifiedCommand('compareWithSelected'), this.compareWithSelected, this); - } - - protected onConfigurationChanged(e: ConfigurationChangeEvent) { - if ( - !configuration.changed(e, configuration.name('views')('results').value) && - !configuration.changed(e, configuration.name('views').value) && - !configuration.changed(e, configuration.name('defaultGravatarsStyle').value) - ) { - return; - } - - if (configuration.changed(e, configuration.name('views')('results')('location').value)) { - this.initialize(this.config.location /*, { showCollapseAll: true } */); - } - - if (!configuration.initializing(e) && this._root !== undefined) { - void this.refresh(RefreshReason.ConfigurationChanged); - } - } - - get config(): ViewsConfig & ResultsViewConfig { - return { ...Container.config.views, ...Container.config.views.results }; - } - - get keepResults(): boolean { - return Container.context.workspaceState.get(WorkspaceState.ViewsResultsKeepResults, false); - } - - clear() { - if (this._root === undefined) return; - - this._root.clear(); - } - - dismissNode(node: ViewNode) { - if (this._root === undefined) return; - - this._root.dismiss(node); - } - - compare(repoPath: string, ref1: string | NamedRef, ref2: string | NamedRef) { - return this.addResults( - new ResultsComparisonNode( - this, - repoPath, - typeof ref1 === 'string' ? { ref: ref1 } : ref1, - typeof ref2 === 'string' ? { ref: ref2 } : ref2 - ) - ); - } - - compareWithSelected(repoPath?: string, ref?: string | NamedRef) { - const root = this.ensureRoot(); - void root.compareWithSelected(repoPath, ref); - } - - selectForCompare(repoPath?: string, ref?: string | NamedRef) { - const root = this.ensureRoot(); - void root.selectForCompare(repoPath, ref); - } - - private async addResults(results: ViewNode) { - const root = this.ensureRoot(); - root.addOrReplace(results, !this.keepResults); - - setTimeout(() => this._tree!.reveal(results, { select: true }), 250); - } - - private setFilesLayout(layout: ViewFilesLayout) { - return configuration.updateEffective(configuration.name('views')('results')('files')('layout').value, layout); - } - - private setKeepResults(enabled: boolean) { - Container.context.workspaceState.update(WorkspaceState.ViewsResultsKeepResults, enabled); - setCommandContext(CommandContext.ViewsResultsKeepResults, enabled); - } - - private swapComparision(node: ViewNode) { - if (!(node instanceof ResultsComparisonNode)) return; - - node.swap(); - } -} diff --git a/src/views/viewBase.ts b/src/views/viewBase.ts index 1342523..62ecbbb 100644 --- a/src/views/viewBase.ts +++ b/src/views/viewBase.ts @@ -17,12 +17,12 @@ import { configuration } from '../configuration'; import { Container } from '../container'; import { Logger } from '../logger'; import { debug, Functions, gate, log } from '../system'; +import { CompareView } from './compareView'; import { FileHistoryView } from './fileHistoryView'; import { LineHistoryView } from './lineHistoryView'; import { ViewNode } from './nodes'; import { isPageable } from './nodes/viewNode'; import { RepositoriesView } from './repositoriesView'; -import { ResultsView } from './resultsView'; import { SearchView } from './searchView'; import { RefreshNodeCommandArgs } from './viewCommands'; @@ -31,7 +31,7 @@ export enum RefreshReason { VisibilityChanged = 'VisibilityChanged' } -export type View = RepositoriesView | FileHistoryView | LineHistoryView | ResultsView | SearchView; +export type View = RepositoriesView | FileHistoryView | LineHistoryView | CompareView | SearchView; export interface TreeViewNodeStateChangeEvent extends TreeViewExpansionEvent { state: TreeItemCollapsibleState; diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index adf1003..7b893c0 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -163,19 +163,19 @@ export class ViewCommands implements Disposable { private compareWithHead(node: ViewNode) { if (!(node instanceof ViewRefNode)) return; - return Container.resultsView.compare(node.repoPath, node.ref, 'HEAD'); + return Container.compareView.compare(node.repoPath, node.ref, 'HEAD'); } private compareWithRemote(node: BranchNode) { if (!node.branch.tracking) return; - return Container.resultsView.compare(node.repoPath, node.branch.tracking, node.ref); + return Container.compareView.compare(node.repoPath, node.branch.tracking, node.ref); } private compareWithWorking(node: ViewNode) { if (!(node instanceof ViewRefNode)) return; - return Container.resultsView.compare(node.repoPath, node.ref, ''); + return Container.compareView.compare(node.repoPath, node.ref, ''); } private async compareAncestryWithWorking(node: BranchNode) { @@ -185,7 +185,7 @@ export class ViewCommands implements Disposable { const commonAncestor = await Container.git.getMergeBase(node.repoPath, branch.ref, node.ref); if (commonAncestor === undefined) return; - return Container.resultsView.compare( + return Container.compareView.compare( node.repoPath, { ref: commonAncestor, label: `ancestry with ${node.ref} (${GitService.shortenSha(commonAncestor)})` }, '' @@ -195,13 +195,13 @@ export class ViewCommands implements Disposable { private compareWithSelected(node: ViewNode) { if (!(node instanceof ViewRefNode)) return; - Container.resultsView.compareWithSelected(node.repoPath, node.ref); + Container.compareView.compareWithSelected(node.repoPath, node.ref); } private selectForCompare(node: ViewNode) { if (!(node instanceof ViewRefNode)) return; - Container.resultsView.selectForCompare(node.repoPath, node.ref); + Container.compareView.selectForCompare(node.repoPath, node.ref); } private compareFileWithSelected(node: ViewNode) {