Browse Source

Changes follow cursor to toggle mode file/line

main
Eric Amodio 4 years ago
parent
commit
b31272c2c9
3 changed files with 18 additions and 6 deletions
  1. +4
    -4
      package.json
  2. +3
    -2
      src/views/fileHistoryView.ts
  3. +11
    -0
      src/views/viewBase.ts

+ 4
- 4
package.json View File

@ -3182,15 +3182,15 @@
},
{
"command": "gitlens.views.fileHistory.setCursorFollowingOn",
"title": "Follow the Cursor",
"title": "Toggle Mode (File)",
"category": "GitLens",
"icon": "$(eye)"
"icon": "$(file)"
},
{
"command": "gitlens.views.fileHistory.setCursorFollowingOff",
"title": "Unfollow the Cursor",
"title": "Toggle Mode (Line)",
"category": "GitLens",
"icon": "$(eye-closed)"
"icon": "$(list-selection)"
},
{
"command": "gitlens.views.fileHistory.setRenameFollowingOn",

+ 3
- 2
src/views/fileHistoryView.ts View File

@ -134,12 +134,13 @@ export class FileHistoryView extends ViewBase
this._followCursor = enabled;
void setCommandContext(CommandContext.ViewsFileHistoryCursorFollowing, enabled);
this.title = this._followCursor ? 'Line History' : 'File History';
this.titleContext = this._followCursor ? this.titleContext : undefined;
const root = this.ensureRoot(true);
root.setEditorFollowing(this._followEditor);
void root.ensureSubscription();
void this.refresh(true);
this.titleContext = this._followCursor ? this.titleContext : undefined;
}
private _followEditor: boolean = true;

+ 11
- 0
src/views/viewBase.ts View File

@ -113,9 +113,20 @@ export abstract class ViewBase> implements TreeData
this.updateTitle();
}
private _updateTitleDebounced: (() => void) | undefined = undefined;
private updateTitle() {
if (this._tree == null) return;
if (this._updateTitleDebounced === undefined) {
this._updateTitleDebounced = Functions.debounce(this.updateTitleCore.bind(this), 100);
}
this._updateTitleDebounced();
}
private updateTitleCore() {
if (this._tree == null) return;
this._tree.title = `${this.title}${this.titleContext ? ` ${GlyphChars.Dot} ${this.titleContext}` : ''}${
this.description ? ` ${this.description}` : ''
}`;

Loading…
Cancel
Save