Przeglądaj źródła

Consolidates gitlens:active* contexts into gitlens:activeFileStatus

Less roundtrips through to the UI on changes for better performance/UX
Also adds "flash" protection to deal with the active editor changing to undefined between changes
main
Eric Amodio 6 lat temu
rodzic
commit
df98b110cc
5 zmienionych plików z 93 dodań i 74 usunięć
  1. +4
    -1
      CHANGELOG.md
  2. +56
    -56
      package.json
  3. +1
    -4
      src/constants.ts
  4. +12
    -5
      src/trackers/documentTracker.ts
  5. +20
    -8
      src/trackers/trackedDocument.ts

+ 4
- 1
CHANGELOG.md Wyświetl plik

@ -14,17 +14,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Changed
- Renames the *GitLens History* explorer to *GitLens File History* explorer for better clarity
### Removed
- Removes `gitlens:activeIsTracked`, `gitlens:activeIsBlameable`, `gitlens:activeIsRevision`, and `gitlens:activeHasRemotes` contexts and consolidates them into `gitlens:activeFileStatus` for better performance and UX
### Fixed
- Fixes [#436](https://github.com/eamodio/vscode-gitlens/issues/436) - Copy to clipboard not working
- Fixes [#442](https://github.com/eamodio/vscode-gitlens/issues/442) - GitLens File History fails if name (or path) starts with -
- Fixes [#440](https://github.com/eamodio/vscode-gitlens/issues/436) - Searching for commits with an empty query yields to no results anymore
- Fixes issue where commands in the editor toolbar would flash unnecessarily when navigating history or switching tabs
- Fixes issue where the *Compare File with Previous Revision* command wouldn't work properly when the file had been renamed in some cases
- Fixes issue where changed files count was wrong when the branch was behind the upstream
- Fixes issue where the *GitLens File History* explorer wasn't being updated automatically for working changes
- Fixes issue where the *Compare File with * Revision* commands in the editor toolbar would show and hide too often because of insignificant focus changes
- Fixes issue where the scope box would be empty when there was no workspace open in the interactive settings editor
## [8.4.1] - 2018-06-19
### Fixed
- Fixes issue with insiders builds because of the new `SymbolInformation` API changes (see [Microsoft/vscode#34968](https://github.com/Microsoft/vscode/issues/34968))

+ 56
- 56
package.json Wyświetl plik

@ -2062,35 +2062,35 @@
},
{
"command": "gitlens.diffWithBranch",
"when": "gitlens:activeIsTracked"
"when": "gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithNext",
"when": "gitlens:activeIsTracked && gitlens:activeIsRevision"
"when": "gitlens:activeFileStatus =~ /tracked/ && gitlens:activeFileStatus =~ /revision/"
},
{
"command": "gitlens.diffWithPrevious",
"when": "!isInDiffEditor && gitlens:activeIsTracked"
"when": "!isInDiffEditor && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithPreviousInDiff",
"when": "isInDiffEditor && gitlens:activeIsTracked"
"when": "isInDiffEditor && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffLineWithPrevious",
"when": "gitlens:activeIsBlameable"
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.diffWithRevision",
"when": "gitlens:activeIsTracked"
"when": "gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithWorking",
"when": "gitlens:activeIsTracked"
"when": "gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffLineWithWorking",
"when": "gitlens:activeIsBlameable"
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.externalDiff",
@ -2102,11 +2102,11 @@
},
{
"command": "gitlens.toggleFileBlame",
"when": "gitlens:activeIsBlameable"
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.clearFileAnnotations",
"when": "gitlens:activeIsBlameable && gitlens:annotationStatus == computed"
"when": "gitlens:activeFileStatus =~ /blameable/ && gitlens:annotationStatus == computed"
},
{
"command": "gitlens.computingFileAnnotations",
@ -2114,11 +2114,11 @@
},
{
"command": "gitlens.toggleFileHeatmap",
"when": "gitlens:activeIsBlameable"
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.toggleFileRecentChanges",
"when": "gitlens:activeIsBlameable"
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.toggleLineBlame",
@ -2150,15 +2150,15 @@
},
{
"command": "gitlens.showQuickCommitDetails",
"when": "gitlens:activeIsBlameable"
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.showQuickCommitFileDetails",
"when": "editorTextFocus && gitlens:activeIsBlameable"
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.showQuickFileHistory",
"when": "gitlens:activeIsTracked"
"when": "gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.showQuickBranchHistory",
@ -2178,11 +2178,11 @@
},
{
"command": "gitlens.copyShaToClipboard",
"when": "gitlens:activeIsBlameable"
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.copyMessageToClipboard",
"when": "gitlens:activeIsBlameable"
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.closeUnchangedFiles",
@ -2202,15 +2202,15 @@
},
{
"command": "gitlens.openCommitInRemote",
"when": "gitlens:activeIsBlameable && gitlens:activeHasRemotes"
"when": "gitlens:activeFileStatus =~ /blameable/ && gitlens:activeFileStatus =~ /remotes/"
},
{
"command": "gitlens.openFileInRemote",
"when": "gitlens:activeIsTracked && gitlens:activeHasRemotes"
"when": "gitlens:activeFileStatus =~ /tracked/ && gitlens:activeFileStatus =~ /remotes/"
},
{
"command": "gitlens.openFileRevision",
"when": "gitlens:activeIsTracked"
"when": "gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.openRepoInRemote",
@ -2218,7 +2218,7 @@
},
{
"command": "gitlens.openWorkingFile",
"when": "gitlens:activeIsRevision"
"when": "gitlens:activeFileStatus =~ /revision/"
},
{
"command": "gitlens.stashApply",
@ -2488,112 +2488,112 @@
"editor/context": [
{
"command": "gitlens.diffLineWithPrevious",
"when": "editorTextFocus && gitlens:activeIsBlameable && config.gitlens.menus.editor.compare",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.compare",
"group": "1_gitlens@1"
},
{
"command": "gitlens.diffLineWithWorking",
"when": "editorTextFocus && gitlens:activeIsBlameable && config.gitlens.menus.editor.compare",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.compare",
"group": "1_gitlens@2"
},
{
"command": "gitlens.openFileInRemote",
"when": "editorTextFocus && gitlens:activeHasRemotes && config.gitlens.menus.editor.remote",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /remotes/ && config.gitlens.menus.editor.remote",
"group": "1_gitlens_1@1"
},
{
"command": "gitlens.openCommitInRemote",
"when": "editorTextFocus && gitlens:activeHasRemotes && config.gitlens.menus.editor.remote",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /remotes/ && config.gitlens.menus.editor.remote",
"group": "1_gitlens_1@2"
},
{
"command": "gitlens.showQuickCommitFileDetails",
"when": "editorTextFocus && gitlens:activeIsBlameable && config.gitlens.menus.editor.details",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.details",
"group": "1_gitlens_1@3"
},
{
"command": "gitlens.showQuickFileHistory",
"when": "gitlens:activeIsTracked && config.gitlens.menus.editor.history",
"when": "gitlens:activeFileStatus =~ /tracked/ && config.gitlens.menus.editor.history",
"group": "3_gitlens@1"
},
{
"command": "gitlens.toggleFileBlame",
"when": "editorTextFocus && gitlens:activeIsBlameable && config.gitlens.menus.editor.blame",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.blame",
"group": "3_gitlens@2"
},
{
"command": "gitlens.copyShaToClipboard",
"when": "editorTextFocus && gitlens:activeIsBlameable && config.gitlens.menus.editor.clipboard",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard",
"group": "9_gitlens@1"
},
{
"command": "gitlens.copyMessageToClipboard",
"when": "editorTextFocus && gitlens:activeIsBlameable && config.gitlens.menus.editor.clipboard",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard",
"group": "9_gitlens@2"
}
],
"editor/title": [
{
"command": "gitlens.diffWithPrevious",
"when": "!isInDiffEditor && gitlens:activeIsTracked && config.gitlens.menus.editorGroup.compare",
"when": "!isInDiffEditor && gitlens:activeFileStatus =~ /tracked/ && config.gitlens.menus.editorGroup.compare",
"group": "navigation@97"
},
{
"command": "gitlens.diffWithPreviousInDiff",
"when": "isInDiffEditor && gitlens:activeIsTracked && config.gitlens.menus.editorGroup.compare",
"when": "isInDiffEditor && gitlens:activeFileStatus =~ /tracked/ && config.gitlens.menus.editorGroup.compare",
"group": "navigation@97"
},
{
"command": "gitlens.diffWithNext",
"when": "gitlens:activeIsTracked && gitlens:activeIsTracked && gitlens:activeIsRevision && config.gitlens.menus.editorGroup.compare",
"when": "gitlens:activeFileStatus =~ /tracked/ && gitlens:activeFileStatus =~ /tracked/ && gitlens:activeFileStatus =~ /revision/ && config.gitlens.menus.editorGroup.compare",
"group": "navigation@98"
},
{
"command": "gitlens.openWorkingFile",
"when": "gitlens:activeIsRevision && resourceScheme != git",
"when": "gitlens:activeFileStatus =~ /revision/ && resourceScheme != git",
"group": "navigation@99"
},
{
"command": "gitlens.openWorkingFile",
"when": "!gitlens:activeIsRevision && resourceScheme != git && isInDiffEditor",
"when": "!gitlens:activeFileStatus =~ /revision/ && resourceScheme != git && isInDiffEditor",
"group": "navigation@99"
},
{
"command": "gitlens.openWorkingFile",
"when": "gitlens:activeIsRevision && resourceScheme == git && !isInDiffEditor",
"when": "gitlens:activeFileStatus =~ /revision/ && resourceScheme == git && !isInDiffEditor",
"group": "navigation@99"
},
{
"command": "gitlens.toggleFileBlame",
"alt": "gitlens.toggleFileRecentChanges",
"when": "gitlens:activeIsBlameable && !gitlens:annotationStatus && config.gitlens.menus.editorGroup.blame",
"when": "gitlens:activeFileStatus =~ /blameable/ && !gitlens:annotationStatus && config.gitlens.menus.editorGroup.blame",
"group": "navigation@100"
},
{
"command": "gitlens.computingFileAnnotations",
"when": "gitlens:activeIsBlameable && gitlens:annotationStatus == computing && config.gitlens.menus.editorGroup.blame",
"when": "gitlens:activeFileStatus =~ /blameable/ && gitlens:annotationStatus == computing && config.gitlens.menus.editorGroup.blame",
"group": "navigation@100"
},
{
"command": "gitlens.clearFileAnnotations",
"when": "gitlens:activeIsBlameable && gitlens:annotationStatus == computed && config.gitlens.menus.editorGroup.blame",
"when": "gitlens:activeFileStatus =~ /blameable/ && gitlens:annotationStatus == computed && config.gitlens.menus.editorGroup.blame",
"group": "navigation@100"
},
{
"command": "gitlens.openFileInRemote",
"when": "gitlens:enabled && gitlens:activeHasRemotes && config.gitlens.menus.editorGroup.remote",
"when": "gitlens:enabled && gitlens:activeFileStatus =~ /remotes/ && config.gitlens.menus.editorGroup.remote",
"group": "4_gitlens"
},
{
"command": "gitlens.showQuickFileHistory",
"when": "editorFocus && gitlens:activeIsTracked && config.gitlens.menus.editorGroup.history",
"when": "editorFocus && gitlens:activeFileStatus =~ /tracked/ && config.gitlens.menus.editorGroup.history",
"group": "4_gitlens"
}
],
"editor/title/context": [
{
"command": "gitlens.openFileInRemote",
"when": "gitlens:enabled && gitlens:activeHasRemotes && config.gitlens.menus.editorTab.remote",
"when": "gitlens:enabled && gitlens:activeFileStatus =~ /remotes/ && config.gitlens.menus.editorTab.remote",
"group": "2_files@100"
},
{
@ -3152,7 +3152,7 @@
{
"command": "gitlens.toggleFileBlame",
"key": "alt+b",
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeIsBlameable"
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.toggleCodeLens",
@ -3192,38 +3192,38 @@
{
"command": "gitlens.diffWithNext",
"key": "alt+.",
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeIsTracked"
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffLineWithPrevious",
"key": "shift+alt+,",
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeIsTracked"
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithPrevious",
"key": "alt+,",
"when": "gitlens:keymap == alternate && editorTextFocus && !isInDiffEditor && gitlens:activeIsTracked"
"when": "gitlens:keymap == alternate && editorTextFocus && !isInDiffEditor && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithPreviousInDiff",
"key": "alt+,",
"when": "gitlens:keymap == alternate && isInDiffEditor && gitlens:activeIsTracked"
"when": "gitlens:keymap == alternate && isInDiffEditor && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffLineWithWorking",
"key": "alt+w",
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeIsTracked"
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithWorking",
"key": "shift+alt+w",
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeIsTracked"
"when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.toggleFileBlame",
"key": "ctrl+shift+g b",
"mac": "cmd+alt+g b",
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsBlameable"
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.toggleCodeLens",
@ -3271,37 +3271,37 @@
"command": "gitlens.diffWithNext",
"key": "ctrl+shift+g .",
"mac": "cmd+alt+g .",
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffLineWithPrevious",
"key": "ctrl+shift+g shift+,",
"mac": "cmd+alt+g shift+,",
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithPrevious",
"key": "ctrl+shift+g ,",
"mac": "cmd+alt+g ,",
"when": "gitlens:keymap == chorded && editorTextFocus && !isInDiffEditor && gitlens:activeIsTracked"
"when": "gitlens:keymap == chorded && editorTextFocus && !isInDiffEditor && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithPreviousInDiff",
"key": "ctrl+shift+g ,",
"mac": "cmd+alt+g ,",
"when": "gitlens:keymap == chorded && isInDiffEditor && gitlens:activeIsTracked"
"when": "gitlens:keymap == chorded && isInDiffEditor && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffLineWithWorking",
"key": "ctrl+shift+g w",
"mac": "cmd+alt+g w",
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "gitlens.diffWithWorking",
"key": "ctrl+shift+g shift+w",
"mac": "cmd+alt+g shift+w",
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeIsTracked"
"when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/"
},
{
"command": "workbench.view.scm",

+ 1
- 4
src/constants.ts Wyświetl plik

@ -24,10 +24,7 @@ export enum BuiltInCommands {
}
export enum CommandContext {
ActiveHasRemotes = 'gitlens:activeHasRemotes',
ActiveIsBlameable = 'gitlens:activeIsBlameable',
ActiveFileIsTracked = 'gitlens:activeIsTracked',
ActiveIsRevision = 'gitlens:activeIsRevision',
ActiveFileStatus = 'gitlens:activeFileStatus',
AnnotationStatus = 'gitlens:annotationStatus',
CanToggleCodeLens = 'gitlens:canToggleCodeLens',
Enabled = 'gitlens:enabled',

+ 12
- 5
src/trackers/documentTracker.ts Wyświetl plik

@ -59,7 +59,7 @@ export class DocumentTracker extends Disposable {
this._disposable = Disposable.from(
configuration.onDidChange(this.onConfigurationChanged, this),
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveTextEditorChanged, 0), this),
window.onDidChangeActiveTextEditor(this.onActiveTextEditorChanged, this),
// window.onDidChangeVisibleTextEditors(Functions.debounce(this.onVisibleEditorsChanged, 5000), this),
workspace.onDidChangeTextDocument(Functions.debounce(this.onTextDocumentChanged, 50), this),
workspace.onDidCloseTextDocument(this.onTextDocumentClosed, this),
@ -100,14 +100,21 @@ export class DocumentTracker extends Disposable {
}
}
private _timer: NodeJS.Timer | undefined;
private onActiveTextEditorChanged(editor: TextEditor | undefined) {
if (editor !== undefined && !isTextEditor(editor)) return;
if (this._timer !== undefined) {
clearTimeout(this._timer);
this._timer = undefined;
}
if (editor === undefined) {
setCommandContext(CommandContext.ActiveIsRevision, false);
setCommandContext(CommandContext.ActiveFileIsTracked, false);
setCommandContext(CommandContext.ActiveIsBlameable, false);
setCommandContext(CommandContext.ActiveHasRemotes, false);
this._timer = setTimeout(() => {
this._timer = undefined;
setCommandContext(CommandContext.ActiveFileStatus, undefined);
}, 250);
return;
}

+ 20
- 8
src/trackers/trackedDocument.ts Wyświetl plik

@ -119,10 +119,7 @@ export class TrackedDocument extends Disposable {
}
activate() {
setCommandContext(CommandContext.ActiveIsRevision, this.isRevision);
setCommandContext(CommandContext.ActiveFileIsTracked, this.isTracked);
setCommandContext(CommandContext.ActiveIsBlameable, this.isBlameable);
setCommandContext(CommandContext.ActiveHasRemotes, this.hasRemotes);
setCommandContext(CommandContext.ActiveFileStatus, this.getStatus());
}
async ensureInitialized() {
@ -200,10 +197,7 @@ export class TrackedDocument extends Disposable {
if (active !== undefined) {
const blameable = this.isBlameable;
setCommandContext(CommandContext.ActiveIsRevision, this.isRevision);
setCommandContext(CommandContext.ActiveFileIsTracked, this.isTracked);
setCommandContext(CommandContext.ActiveIsBlameable, blameable);
setCommandContext(CommandContext.ActiveHasRemotes, this.hasRemotes);
setCommandContext(CommandContext.ActiveFileStatus, this.getStatus());
if (!options.initializing && wasBlameable !== blameable) {
const e = { editor: active, document: this, blameable: blameable } as DocumentBlameStateChangeEvent<T>;
@ -212,4 +206,22 @@ export class TrackedDocument extends Disposable {
}
}
}
private getStatus() {
let status = '';
if (this.isTracked) {
status += 'tracked|';
}
if (this.isBlameable) {
status += 'blameable|';
}
if (this.isRevision) {
status += 'revision|';
}
if (this.hasRemotes) {
status += 'remotes|';
}
return status ? status : undefined;
}
}

Ładowanie…
Anuluj
Zapisz