Skip to content

Commit

Permalink
Support forks of vscode in web extension
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Nov 22, 2024
1 parent 24ce544 commit 26e8f69
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
21 changes: 21 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import * as vscode from 'vscode';

export class Utils {
private static appNames = {
'Arduino IDE': 'arduino',
'Azure Data Studio': 'azdata',
Cursor: 'cursor',
Onivim: 'onivim',
'Onivim 2': 'onivim',
'SQL Operations Studio': 'sqlops',
'Visual Studio Code': 'vscode',
Windsurf: 'windsurf',
};

public static quote(str: string): string {
if (str.includes(' ')) return `"${str.replace('"', '\\"')}"`;
return str;
Expand Down Expand Up @@ -104,4 +115,14 @@ export class Utils {
if (!uri) return false;
return uri.scheme == 'pr';
}

public static getEditorName(): string {
if (this.appNames[vscode.env.appName]) {
return this.appNames[vscode.env.appName];
} else if (vscode.env.appName.toLowerCase().includes('visual')) {
return 'vscode';
} else {
return vscode.env.appName.replace(/\s/g, '').toLowerCase();
}
}
}
19 changes: 1 addition & 18 deletions src/wakatime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ interface FileSelectionMap {
}

export class WakaTime {
private appNames = {
'Arduino IDE': 'arduino',
'Azure Data Studio': 'azdata',
Cursor: 'cursor',
Onivim: 'onivim',
'Onivim 2': 'onivim',
'SQL Operations Studio': 'sqlops',
'Visual Studio Code': 'vscode',
Windsurf: 'windsurf',
};
private agentName: string;
private extension: any;
private statusBar?: vscode.StatusBarItem = undefined;
Expand Down Expand Up @@ -85,14 +75,7 @@ export class WakaTime {

let extension = vscode.extensions.getExtension('WakaTime.vscode-wakatime');
this.extension = (extension != undefined && extension.packageJSON) || { version: '0.0.0' };

if (this.appNames[vscode.env.appName]) {
this.agentName = this.appNames[vscode.env.appName];
} else if (vscode.env.appName.toLowerCase().includes('visual')) {
this.agentName = 'vscode';
} else {
this.agentName = vscode.env.appName.replace(/\s/g, '').toLowerCase();
}
this.agentName = Utils.getEditorName();

this.options.getSetting('settings', 'disabled', false, (disabled: Setting) => {
this.disabled = disabled.value === 'true';
Expand Down
2 changes: 1 addition & 1 deletion src/web/wakatime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class WakaTime {

let extension = vscode.extensions.getExtension('WakaTime.vscode-wakatime');
this.extension = (extension != undefined && extension.packageJSON) || { version: '0.0.0' };
this.agentName = 'vscode';
this.agentName = Utils.getEditorName();

this.disabled = this.config.get('wakatime.disabled') === 'true';
if (this.disabled) {
Expand Down

0 comments on commit 26e8f69

Please sign in to comment.