TOPLLab / WARDuino-VSCode

🕵️ A VSCode debugger plugin for WARDuino.
Mozilla Public License 2.0
2 stars 2 forks source link

Display column information #109

Closed tolauwae closed 1 year ago

tolauwae commented 1 year ago

Use column info in debugger, both in the callstack view and in the main view (current position marker).

tolauwae commented 1 year ago

This PR is waiting on #98.

carllocos commented 1 year ago

I also just now force-pushed on this branch with the new content of main.

carllocos commented 1 year ago

@tolauwae I think I understand why it does not work for Wast.

When debugging Wast the line numbers and column numbers are printed as a json in the form of "@ { line: 5, col_start: 29, col_end: 38 }". The column number for that JSON should thus be accessed as col_start and not column but this is not what happens as shown in line https://github.com/TOPLLab/WARDuino-VSCode/blob/7fa69d84ee22fd3b4a2bc2966a0303d32b54beb5/src/CompilerBridges/WASMCompilerBridge.ts#L60

The solution is to either 1. change the WABT to print the json in the expected format i.e., use column instead of col_start or to 2. change the extracLineInfo method to account for the possibility that the json contains col_start instead of column.

I tried the later solution which in my case successfully fixes the column highlighting for Wast. Herefore I rewrote extractLineInfo to become

function extractLineInfo(lineString: string): LineInfo {
    lineString = lineString.substring(1);
    const parsed: any = parseUtils.jsonParse(lineString);
    if (parsed.column === undefined && parsed.col_start !== undefined) {
        parsed.column = parsed.col_start;
    }
    return parsed;
}

This issue is in my opinion a separate bug that could be fixed via a separate PR and should therefore not stop the merge of this PR but if you rather we could also first fix the bug as part of this PR.