Skip to content

Commit

Permalink
Add more sofisticated tooltip with current version
Browse files Browse the repository at this point in the history
  • Loading branch information
jiribenes committed Aug 10, 2024
1 parent edd47d6 commit a6de7ad
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/effektManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class EffektManager {
private serverStatus: 'starting' | 'running' | 'stopped' | 'error' = 'stopped';
private outputChannel: vscode.OutputChannel;
private effektNPMPackage: string = '@effekt-lang/effekt';
private effektVersion: string | null = null;

constructor() {
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
Expand Down Expand Up @@ -110,10 +111,12 @@ export class EffektManager {
try {
const effektPath = await this.getEffektExecutable();
const currentVersion = await this.execCommand(`"${effektPath}" --version`);
this.effektVersion = semver.clean(currentVersion, true)

const latestVersion = await this.getLatestNPMVersion(this.effektNPMPackage);

// check if the latest version strictly newer than the current version
if (semver.gt(latestVersion, semver.clean(currentVersion, true) || '', true)) {
if (semver.gt(latestVersion, this.effektVersion || '', true)) {
return this.promptForAction(latestVersion, 'update');
}

Expand Down Expand Up @@ -258,7 +261,15 @@ export class EffektManager {

const config = statusConfig[this.serverStatus];
this.statusBarItem.text = `Ξ Effekt ${config.icon}`;
this.statusBarItem.tooltip = `${config.tooltip}\n\nClick to check for updates`;
this.statusBarItem.tooltip = new vscode.MarkdownString(`${config.tooltip}\n\n`
+ `_Click to check for updates_\n\n`
+ `---\n`
+ `**Effekt Information:**\n`
+ `- Version: ${this.effektVersion || '<unknown>'}\n`
+ `- Status: ${this.serverStatus}\n`
+ `- Backend: ${this.config.get<string>("backend") || '<unknown>'}`);
this.statusBarItem.tooltip.isTrusted = true;

this.statusBarItem.color = config.color ? new vscode.ThemeColor(config.color) : undefined;
this.statusBarItem.backgroundColor = config.bgColor ? new vscode.ThemeColor(config.bgColor) : undefined;
this.statusBarItem.show();
Expand Down

0 comments on commit a6de7ad

Please sign in to comment.