浏览代码

Adds pause/resume tracking support in file/line explorers

main
Eric Amodio 6 年前
父节点
当前提交
66d1ff1896
共有 15 个文件被更改,包括 172 次插入3 次删除
  1. +4
    -0
      images/dark/icon-location-filled.svg
  2. +4
    -0
      images/dark/icon-location.svg
  3. +4
    -0
      images/dark/icon-pin.svg
  4. +4
    -0
      images/dark/icon-pinned.svg
  5. +4
    -0
      images/light/icon-location-filled.svg
  6. +4
    -0
      images/light/icon-location.svg
  7. +4
    -0
      images/light/icon-pin.svg
  8. +4
    -0
      images/light/icon-pinned.svg
  9. +74
    -2
      package.json
  10. +2
    -0
      src/constants.ts
  11. +18
    -0
      src/views/fileHistoryExplorer.ts
  12. +18
    -0
      src/views/lineHistoryExplorer.ts
  13. +20
    -1
      src/views/nodes/explorerNode.ts
  14. +4
    -0
      src/views/nodes/fileHistoryTrackerNode.ts
  15. +4
    -0
      src/views/nodes/lineHistoryTrackerNode.ts

+ 4
- 0
images/dark/icon-location-filled.svg 查看文件

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22">
<path fill="#c5c5c5" d="M 14 8.5 C 14 13.02 8 19 8 19 C 8 19 2 13.02 2 8.5 C 2 5.5 4.69 3 8 3 C 11.31 3 14 5.5 14 8.5 Z M 8 6.5 C 6.89 6.5 6 7.39 6 8.5 C 6 9.61 6.89 10.5 8 10.5 C 9.11 10.5 10 9.61 10 8.5 C 10 7.39 9.11 6.5 8 6.5 Z"/>
</svg>

+ 4
- 0
images/dark/icon-location.svg 查看文件

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22">
<path fill="#c5c5c5" d="m8,3c-3.31,0 -6,2.5 -6,5.5c0,4.52 6,10.5 6,10.5s6,-5.98 6,-10.5c0,-3 -2.69,-5.5 -6,-5.5zm0,14.55c-1.86,-2.03 -5,-6.11 -5,-9.05c0,-2.48 2.25,-4.5 5,-4.5c1.34,0 2.61,0.48 3.56,1.36c0.92,0.86 1.44,1.97 1.44,3.14c0,2.94 -3.14,7.02 -5,9.05zm2,-9.05c0,1.11 -0.89,2 -2,2c-1.11,0 -2,-0.89 -2,-2c0,-1.11 0.89,-2 2,-2c1.11,0 2,0.89 2,2z"/>
</svg>

+ 4
- 0
images/dark/icon-pin.svg 查看文件

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22">
<path fill="#c5c5c5" d="m10,4.34653l0,0.8l0.5,1l-4.5,3l-3.8,0c-0.44,0 -0.67,0.53 -0.34,0.86l3.14,3.14l-4,5l5,-4l3.14,3.14a0.5,0.5 0 0 0 0.86,-0.34l0,-3.8l3,-4.5l1,0.5l0.8,0c0.44,0 0.67,-0.53 0.34,-0.86l-4.28,-4.28a0.5,0.5 0 0 0 -0.86,0.34z"/>
</svg>

+ 4
- 0
images/dark/icon-pinned.svg 查看文件

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22">
<path fill="#c5c5c5" d="m4.753,4.986l0.566,0.566l1.06,0.353l-1.06,5.303l-2.687,2.687c-0.312,0.312 -0.099,0.849 0.367,0.849l4.441,0l0.707,6.364l0.707,-6.364l4.441,0c0.385,0.007 0.633,-0.405 0.447,-0.742c-0.022,-0.039 -0.049,-0.075 -0.08,-0.107l-2.687,-2.687l-1.06,-5.303l1.06,-0.353l0.566,-0.566c0.311,-0.311 0.099,-0.849 -0.368,-0.849l-6.052,0c-0.385,-0.007 -0.633,0.405 -0.447,0.742c0.021,0.039 0.048,0.075 0.079,0.107z"/>
</svg>

+ 4
- 0
images/light/icon-location-filled.svg 查看文件

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22">
<path fill="#424242" d="M 14 8.5 C 14 13.02 8 19 8 19 C 8 19 2 13.02 2 8.5 C 2 5.5 4.69 3 8 3 C 11.31 3 14 5.5 14 8.5 Z M 8 6.5 C 6.89 6.5 6 7.39 6 8.5 C 6 9.61 6.89 10.5 8 10.5 C 9.11 10.5 10 9.61 10 8.5 C 10 7.39 9.11 6.5 8 6.5 Z"/>
</svg>

+ 4
- 0
images/light/icon-location.svg 查看文件

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22">
<path fill="#424242" d="m8,3c-3.31,0 -6,2.5 -6,5.5c0,4.52 6,10.5 6,10.5s6,-5.98 6,-10.5c0,-3 -2.69,-5.5 -6,-5.5zm0,14.55c-1.86,-2.03 -5,-6.11 -5,-9.05c0,-2.48 2.25,-4.5 5,-4.5c1.34,0 2.61,0.48 3.56,1.36c0.92,0.86 1.44,1.97 1.44,3.14c0,2.94 -3.14,7.02 -5,9.05zm2,-9.05c0,1.11 -0.89,2 -2,2c-1.11,0 -2,-0.89 -2,-2c0,-1.11 0.89,-2 2,-2c1.11,0 2,0.89 2,2z"/>
</svg>

+ 4
- 0
images/light/icon-pin.svg 查看文件

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22">
<path fill="#424242" d="m10,4.34653l0,0.8l0.5,1l-4.5,3l-3.8,0c-0.44,0 -0.67,0.53 -0.34,0.86l3.14,3.14l-4,5l5,-4l3.14,3.14a0.5,0.5 0 0 0 0.86,-0.34l0,-3.8l3,-4.5l1,0.5l0.8,0c0.44,0 0.67,-0.53 0.34,-0.86l-4.28,-4.28a0.5,0.5 0 0 0 -0.86,0.34z"/>
</svg>

+ 4
- 0
images/light/icon-pinned.svg 查看文件

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 22">
<path fill="#424242" d="m4.753,4.986l0.566,0.566l1.06,0.353l-1.06,5.303l-2.687,2.687c-0.312,0.312 -0.099,0.849 0.367,0.849l4.441,0l0.707,6.364l0.707,-6.364l4.441,0c0.385,0.007 0.633,-0.405 0.447,-0.742c-0.022,-0.039 -0.049,-0.075 -0.08,-0.107l-2.687,-2.687l-1.06,-5.303l1.06,-0.353l0.566,-0.566c0.311,-0.311 0.099,-0.849 -0.368,-0.849l-6.052,0c-0.385,-0.007 -0.633,0.405 -0.447,0.742c0.021,0.039 0.048,0.075 0.079,0.107z"/>
</svg>

+ 74
- 2
package.json 查看文件

@ -2134,6 +2134,24 @@
"category": "GitLens"
},
{
"command": "gitlens.fileHistoryExplorer.setEditorFollowingOn",
"title": "Resume File Tracking",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-location.svg",
"light": "images/light/icon-location.svg"
}
},
{
"command": "gitlens.fileHistoryExplorer.setEditorFollowingOff",
"title": "Pause File Tracking",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-location-filled.svg",
"light": "images/light/icon-location-filled.svg"
}
},
{
"command": "gitlens.fileHistoryExplorer.setRenameFollowingOn",
"title": "Follow Renames",
"category": "GitLens"
@ -2158,6 +2176,24 @@
"category": "GitLens"
},
{
"command": "gitlens.lineHistoryExplorer.setEditorFollowingOn",
"title": "Resume Line Tracking",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-location.svg",
"light": "images/light/icon-location.svg"
}
},
{
"command": "gitlens.lineHistoryExplorer.setEditorFollowingOff",
"title": "Pause Line Tracking",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-location-filled.svg",
"light": "images/light/icon-location-filled.svg"
}
},
{
"command": "gitlens.lineHistoryExplorer.setRenameFollowingOn",
"title": "Follow Renames",
"category": "GitLens"
@ -2662,6 +2698,14 @@
"when": "false"
},
{
"command": "gitlens.fileHistoryExplorer.setEditorFollowingOn",
"when": "false"
},
{
"command": "gitlens.fileHistoryExplorer.setEditorFollowingOff",
"when": "false"
},
{
"command": "gitlens.fileHistoryExplorer.setRenameFollowingOn",
"when": "false"
},
@ -2678,6 +2722,14 @@
"when": "false"
},
{
"command": "gitlens.lineHistoryExplorer.setEditorFollowingOn",
"when": "false"
},
{
"command": "gitlens.lineHistoryExplorer.setEditorFollowingOff",
"when": "false"
},
{
"command": "gitlens.lineHistoryExplorer.setRenameFollowingOn",
"when": "false"
},
@ -2998,9 +3050,19 @@
"group": "2_gitlens"
},
{
"command": "gitlens.fileHistoryExplorer.setEditorFollowingOn",
"when": "view =~ /^gitlens.fileHistoryExplorer:/ && !gitlens:fileHistoryExplorer:editorFollowing",
"group": "navigation@1"
},
{
"command": "gitlens.fileHistoryExplorer.setEditorFollowingOff",
"when": "view =~ /^gitlens.fileHistoryExplorer:/ && gitlens:fileHistoryExplorer:editorFollowing",
"group": "navigation@1"
},
{
"command": "gitlens.fileHistoryExplorer.refresh",
"when": "view =~ /^gitlens.fileHistoryExplorer:/",
"group": "navigation@1"
"group": "navigation@2"
},
{
"command": "gitlens.fileHistoryExplorer.setRenameFollowingOn",
@ -3013,9 +3075,19 @@
"group": "1_gitlens"
},
{
"command": "gitlens.lineHistoryExplorer.setEditorFollowingOn",
"when": "view =~ /^gitlens.lineHistoryExplorer:/ && !gitlens:lineHistoryExplorer:editorFollowing",
"group": "navigation@1"
},
{
"command": "gitlens.lineHistoryExplorer.setEditorFollowingOff",
"when": "view =~ /^gitlens.lineHistoryExplorer:/ && gitlens:lineHistoryExplorer:editorFollowing",
"group": "navigation@1"
},
{
"command": "gitlens.lineHistoryExplorer.refresh",
"when": "view =~ /^gitlens.lineHistoryExplorer:/",
"group": "navigation@1"
"group": "navigation@2"
},
{
"command": "gitlens.lineHistoryExplorer.setRenameFollowingOn",

+ 2
- 0
src/constants.ts 查看文件

@ -34,7 +34,9 @@ export enum CommandContext {
ExplorersCanCompare = 'gitlens:explorers:canCompare',
HasRemotes = 'gitlens:hasRemotes',
FileHistoryExplorer = 'gitlens:fileHistoryExplorer',
FileHistoryExplorerEditorFollowing = 'gitlens:fileHistoryExplorer:editorFollowing',
LineHistoryExplorer = 'gitlens:lineHistoryExplorer',
LineHistoryExplorerEditorFollowing = 'gitlens:lineHistoryExplorer:editorFollowing',
Key = 'gitlens:key',
KeyMap = 'gitlens:keymap',
RepositoriesExplorer = 'gitlens:repositoriesExplorer',

+ 18
- 0
src/views/fileHistoryExplorer.ts 查看文件

@ -26,6 +26,16 @@ export class FileHistoryExplorer extends ExplorerBase {
);
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOn'),
() => this.setEditorFollowing(true),
this
);
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOff'),
() => this.setEditorFollowing(false),
this
);
commands.registerCommand(
this.getQualifiedCommand('setRenameFollowingOn'),
() => this.setRenameFollowing(true),
this
@ -56,6 +66,7 @@ export class FileHistoryExplorer extends ExplorerBase {
configuration.changed(e, configuration.name('fileHistoryExplorer')('location').value)
) {
setCommandContext(CommandContext.FileHistoryExplorer, this.config.enabled ? this.config.location : false);
setCommandContext(CommandContext.FileHistoryExplorerEditorFollowing, true);
}
if (initializing || configuration.changed(e, configuration.name('fileHistoryExplorer')('location').value)) {
@ -71,6 +82,13 @@ export class FileHistoryExplorer extends ExplorerBase {
return { ...Container.config.explorers, ...Container.config.fileHistoryExplorer };
}
private setEditorFollowing(enabled: boolean) {
setCommandContext(CommandContext.FileHistoryExplorerEditorFollowing, enabled);
if (this._root !== undefined) {
this._root.setEditorFollowing(enabled);
}
}
private setRenameFollowing(enabled: boolean) {
return configuration.updateEffective(
configuration.name('advanced')('fileHistoryFollowsRenames').value,

+ 18
- 0
src/views/lineHistoryExplorer.ts 查看文件

@ -25,6 +25,16 @@ export class LineHistoryExplorer extends ExplorerBase {
this
);
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOn'),
() => this.setEditorFollowing(true),
this
);
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOff'),
() => this.setEditorFollowing(false),
this
);
commands.registerCommand(
this.getQualifiedCommand('setRenameFollowingOn'),
() => this.setRenameFollowing(true),
this
@ -55,6 +65,7 @@ export class LineHistoryExplorer extends ExplorerBase {
configuration.changed(e, configuration.name('lineHistoryExplorer')('location').value)
) {
setCommandContext(CommandContext.LineHistoryExplorer, this.config.enabled ? this.config.location : false);
setCommandContext(CommandContext.LineHistoryExplorerEditorFollowing, true);
}
if (initializing || configuration.changed(e, configuration.name('lineHistoryExplorer')('location').value)) {
@ -70,6 +81,13 @@ export class LineHistoryExplorer extends ExplorerBase {
return { ...Container.config.explorers, ...Container.config.lineHistoryExplorer };
}
private setEditorFollowing(enabled: boolean) {
setCommandContext(CommandContext.LineHistoryExplorerEditorFollowing, enabled);
if (this._root !== undefined) {
this._root.setEditorFollowing(enabled);
}
}
private setRenameFollowing(enabled: boolean) {
return configuration.updateEffective(
configuration.name('advanced')('fileHistoryFollowsRenames').value,

+ 20
- 1
src/views/nodes/explorerNode.ts 查看文件

@ -130,6 +130,21 @@ export abstract class SubscribeableExplorerNode exte
}
}
private _canSubscribe: boolean = true;
protected get canSubscribe(): boolean {
return this._canSubscribe;
}
protected set canSubscribe(value: boolean) {
if (this._canSubscribe === value) return;
this._canSubscribe = value;
void this.ensureSubscription();
if (value) {
void this.explorer.refreshNode(this);
}
}
protected abstract async subscribe(): Promise<Disposable | undefined>;
protected unsubscribe(): void {
if (this._subscription !== undefined) {
@ -152,7 +167,11 @@ export abstract class SubscribeableExplorerNode exte
async ensureSubscription() {
// We only need to subscribe if we are visible and if auto-refresh enabled (when supported)
if (!this.explorer.visible || (supportsAutoRefresh(this.explorer) && !this.explorer.autoRefresh)) {
if (
!this.canSubscribe ||
!this.explorer.visible ||
(supportsAutoRefresh(this.explorer) && !this.explorer.autoRefresh)
) {
this.unsubscribe();
return;

+ 4
- 0
src/views/nodes/fileHistoryTrackerNode.ts 查看文件

@ -102,6 +102,10 @@ export class FileHistoryTrackerNode extends SubscribeableExplorerNode
return false;
}
setEditorFollowing(enabled: boolean) {
this.canSubscribe = enabled;
}
protected async subscribe() {
return Disposable.from(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveEditorChanged, 500), this)

+ 4
- 0
src/views/nodes/lineHistoryTrackerNode.ts 查看文件

@ -94,6 +94,10 @@ export class LineHistoryTrackerNode extends SubscribeableExplorerNode
return false;
}
setEditorFollowing(enabled: boolean) {
this.canSubscribe = enabled;
}
protected async subscribe() {
if (Container.lineTracker.isSubscribed(this)) return undefined;

正在加载...
取消
保存