Skip to content

Commit dcba988

Browse files
committed
some questions as comments
1 parent 082b679 commit dcba988

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/programflow-visualization/frontend/visualization_panel.ts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,34 +196,45 @@ export class VisualizationPanel {
196196

197197
private async updateLineHighlight(remove: boolean = false) {
198198
if (this._trace.length === 0) {
199+
this._outChannel.appendLine("updateLineHighlight: no trace available, aborting");
199200
return;
200201
}
202+
const traceFile = this._trace[this._traceIndex][3]!;
201203
let editor: vscode.TextEditor | undefined = vscode.window.visibleTextEditors.filter(
202-
editor => path.basename(editor.document.uri.path) === path.basename(this._trace[this._traceIndex][3]!)
204+
editor => path.basename(editor.document.uri.path) === path.basename(traceFile)
203205
)[0];
204206

205-
const openPath = vscode.Uri.parse(this._trace[this._traceIndex][3]!);
207+
const openPath = vscode.Uri.parse(traceFile);
206208
if (!editor || editor.document.uri.path !== openPath.path) {
209+
// How can it be that editor is not null/undefined, but the path does not match?
207210
await vscode.commands.executeCommand('workbench.action.focusFirstEditorGroup');
208211
const document = await vscode.workspace.openTextDocument(openPath);
209212
editor = await vscode.window.showTextDocument(document);
210213
}
211214

212-
if (remove || editor.document.lineCount < this._trace[this._traceIndex][0]) {
215+
const traceLine = this._trace[this._traceIndex][0];
216+
if (remove) {
217+
this._outChannel.appendLine(
218+
"updateLineHighlight: removing highlighting in " + editor.document.fileName);
219+
editor.setDecorations(nextLineExecuteHighlightType, []);
220+
} else if (editor.document.lineCount < traceLine) {
221+
// How can it be that traceLine is out of range?
222+
this._outChannel.appendLine(
223+
"updateLineHighlight: removing highlighting in " + editor.document.fileName +
224+
"(out of range)");
213225
editor.setDecorations(nextLineExecuteHighlightType, []);
214226
} else {
215-
this.setNextLineHighlighting(editor);
216-
}
217-
}
218-
219-
private setNextLineHighlighting(editor: vscode.TextEditor) {
220-
if (this._trace.length === 0) {
221-
return;
222-
}
223-
const nextLine = this._trace[this._traceIndex][0] - 1;
224-
225-
if (nextLine > -1) {
226-
this.setEditorDecorations(editor, nextLineExecuteHighlightType, nextLine);
227+
const hlLine = traceLine - 1; // why - 1
228+
if (hlLine > -1) {
229+
this._outChannel.appendLine(
230+
"updateLineHighlight: highlighting line " + hlLine + " in " + editor.document.fileName);
231+
this.setEditorDecorations(editor, nextLineExecuteHighlightType, hlLine);
232+
} else {
233+
// how can this happen?
234+
this._outChannel.appendLine(
235+
"updateLineHighlight: cannot highlight line " + hlLine + " in " +
236+
editor.document.fileName + "(out of range)");
237+
}
227238
}
228239
}
229240

src/programflow-visualization/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type Failure = { errorMessage: string };
77

88
// State Types for the Frontend
99
type FrontendTrace = Array<FrontendTraceElem>;
10+
// FIXME: what are this array elements? Why isn't there a type with named fields?
1011
type FrontendTraceElem = [number, string, string, string, string];
1112
// ############################################################################################
1213
// State Types for the Backend

0 commit comments

Comments
 (0)