Skip to content

Commit 31fad56

Browse files
committed
Merge branch 'master' of gitlab.com:senx/vscode-warpscriptlanguage
2 parents 88b95dd + 90627d1 commit 31fad56

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"author": "SenX <contact@senx.io>",
1313
"icon": "images/w.png",
1414
"license": "Apache-2.0",
15-
"version": "2.3.0",
15+
"version": "2.3.1",
1616
"publisher": "senx",
1717
"engines": {
1818
"vscode": "^1.87.0"
@@ -139,14 +139,14 @@
139139
"group": "Warp 10"
140140
},
141141
{
142-
"when": "resourceLangId == warpscript && config.warpscript.traceToken && senx.warpscript-language.loaded",
142+
"when": "resourceLangId == warpscript && warpscript.showProfile && senx.warpscript-language.loaded",
143143
"command": "extension.profile",
144144
"group": "Warp 10"
145145
}
146146
],
147147
"editor/title": [
148148
{
149-
"when": "resourceLangId == warpscript && config.warpscript.traceToken && senx.warpscript-language.loaded",
149+
"when": "resourceLangId == warpscript && warpscript.showProfile && senx.warpscript-language.loaded",
150150
"command": "extension.profile",
151151
"group": "navigation"
152152
},

src/extension.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import WSDiagnostics from './providers/wsDiagnostics';
4242
import { FileAccessor } from './debug/warp10DebugRuntime';
4343
import { Warp10DebugSession } from './debug/warp10Debug';
4444
import ProfilerCommand from './features/profiler';
45+
import WarpScriptParser from './warpScriptParser';
4546

4647
export class SharedMem {
4748
private static registry: any = {};
@@ -149,8 +150,16 @@ export function activate(context: ExtensionContext) {
149150
let wsDiagnostics = new WSDiagnostics(context);
150151
wsDiagnostics.initializeDiagnostics();
151152

152-
//each time focus change, we look at the file type and file name. Json + special name => stack preview.
153+
// each time focus change, we look at the file type and file name. Json + special name => stack preview.
153154
window.onDidChangeActiveTextEditor((textEditor: TextEditor | undefined) => {
155+
let load = false;
156+
if(textEditor?.document?.languageId === 'warpscript') {
157+
const ws = textEditor.document.getText()
158+
const commentsCommands = WarpScriptParser.extractSpecialComments(ws ?? "");
159+
const endpoint = commentsCommands.endpoint ?? workspace.getConfiguration().get("warpscript.Warp10URL");
160+
load = !!(workspace.getConfiguration().get<any>("warpscript.TraceTokensPerWarp10URL")?? {})[endpoint];
161+
}
162+
commands.executeCommand('setContext', 'warpscript.showProfile', load);
154163
StatusbarUi.Init();
155164
if (!WarpScriptExtGlobals.weAreClosingFilesFlag &&
156165
typeof textEditor !== 'undefined' &&

src/static/profile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ window.addEventListener('message', event => {
2424
Name: getName(p),
2525
Calls: p[4],
2626
'Total time': p[5] + ' ns',
27-
'Time per call': Math.round(getPerCal(profile[5], profile[4]) * 100) / 100 + ' ns'
27+
'Time per call': (Math.round(getPerCal(p[5], p[4]) * 100) / 100) + ' ns'
2828
}));
2929

3030
document.getElementById('profile').addEventListener('mouseout', () => unhighlight());

0 commit comments

Comments
 (0)