Skip to content

Commit

Permalink
fix bug in with property vs accessor api for TreeItem in https://gith…
Browse files Browse the repository at this point in the history
  • Loading branch information
kortina committed Jul 15, 2024
1 parent d4520b2 commit ef270b7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/BacklinksTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class BacklinkItem extends vscode.TreeItem {
) {
super(label, collapsibleState);
this.filename = filename || '';
this.command = this._command();
this.tooltip = this._tooltip();
this.description = this._description();
this.iconPath = this._iconPath();
}

// return the 1 collapsible Item for each file
Expand All @@ -145,7 +149,7 @@ class BacklinkItem extends vscode.TreeItem {
return new BacklinkItem(label, cs, undefined, location, filename);
}

get command(): vscode.Command | undefined {
private _command(): vscode.Command | undefined {
if (this.location) {
return {
command: 'vscode.open',
Expand All @@ -161,7 +165,7 @@ class BacklinkItem extends vscode.TreeItem {
}
}

get tooltip(): string {
private _tooltip(): string {
return [this.filename, this.lineText, this.description].filter(Boolean).join(': ');
}

Expand All @@ -171,7 +175,7 @@ class BacklinkItem extends vscode.TreeItem {
}
}

get description(): string {
private _description(): string {
let d = ``;
if (this.location) {
let lines = (fs.readFileSync(this.location?.uri.fsPath) || '').toString().split(/\r?\n/);
Expand All @@ -190,7 +194,7 @@ class BacklinkItem extends vscode.TreeItem {
return d;
}

get iconPath(): vscode.ThemeIcon | undefined {
private _iconPath(): vscode.ThemeIcon | undefined {
// to leave more room for the ref text,
// don't use an icon for each line
return this.location ? undefined : new vscode.ThemeIcon('references');
Expand Down

0 comments on commit ef270b7

Please sign in to comment.