Skip to content

Commit 1ed94eb

Browse files
committed
Fixes issue with file/line pinning getting lost
1 parent a714693 commit 1ed94eb

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
4949
- Fixes an issue where many views wouldn't refresh properly when going from no items to some items
5050
- Fixes an issue where _Publish Branch_ was incorrectly showing up on remote branches
5151
- Fixes an issue where the _Open Directory Compare \*_ commands failed to work
52+
- Fixes an issue where pinning a file/line to the _File History_ view or _Line History_ view would get lost if the view was collapsed and expanded
5253

5354
### Removed
5455

src/views/lineHistoryView.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export class LineHistoryView extends ViewBase<LineHistoryTrackerNode, LineHistor
1313

1414
constructor() {
1515
super('gitlens.views.lineHistory', 'Line History');
16+
17+
void setContext(ContextKeys.ViewsLineHistoryEditorFollowing, true);
1618
}
1719

1820
protected get showCollapseAll(): boolean {
@@ -69,16 +71,25 @@ export class LineHistoryView extends ViewBase<LineHistoryTrackerNode, LineHistor
6971
}
7072

7173
private setEditorFollowing(enabled: boolean) {
74+
const root = this.ensureRoot();
75+
if (!root.hasUri) return;
76+
7277
void setContext(ContextKeys.ViewsLineHistoryEditorFollowing, enabled);
78+
7379
this.root?.setEditorFollowing(enabled);
7480

7581
if (this.description?.endsWith(pinnedSuffix)) {
7682
if (enabled) {
7783
this.description = this.description.substr(0, this.description.length - pinnedSuffix.length);
7884
}
79-
} else if (!enabled) {
85+
} else if (!enabled && this.description != null) {
8086
this.description += pinnedSuffix;
8187
}
88+
89+
if (enabled) {
90+
void root.ensureSubscription();
91+
void this.refresh(true);
92+
}
8293
}
8394

8495
private setShowAvatars(enabled: boolean) {

src/views/nodes/fileHistoryTrackerNode.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<FileHistoryVie
119119
async refresh(reset: boolean = false) {
120120
const cc = Logger.getCorrelationContext();
121121

122+
if (!this.canSubscribe) return false;
123+
122124
if (reset) {
123125
this.setUri();
124126
this.resetChild();

src/views/nodes/lineHistoryTrackerNode.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode<FileHistoryVie
125125
async refresh(reset: boolean = false) {
126126
const cc = Logger.getCorrelationContext();
127127

128+
if (!this.canSubscribe) return false;
129+
128130
if (reset) {
129131
this.setUri();
130132
this._editorContents = undefined;

0 commit comments

Comments
 (0)