Skip to content

Commit

Permalink
Fix inline opt-remarks: toggling a filter off did not remove the rema…
Browse files Browse the repository at this point in the history
…rks from the display. (compiler-explorer#6407)

No idea how this worked on my machine prior to submitting...
Anyway, fixed now.
  • Loading branch information
OfekShilon authored Apr 28, 2024
1 parent 8d3ba37 commit 9f5906a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions static/panes/opt-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,25 @@ export class Opt extends MonacoPane<monaco.editor.IStandaloneCodeEditor, OptStat
});
const groupedRemarks = _(remarksToDisplay).groupBy(x => x.DebugLoc.Line);

const resLines = [...this.srcAsOptview];
for (const [key, value] of Object.entries(groupedRemarks)) {
const origLineNum = Number(key);
const curLineNum = this.srcAsOptview.findIndex(srcLine => srcLine.srcLine === origLineNum);
const curLineNum = resLines.findIndex(line => line.srcLine === origLineNum);
const contents = value.map(rem => ({
text: rem.displayString,
srcLine: -1,
optClass: rem.optType,
}));
this.srcAsOptview.splice(curLineNum, 0, ...contents);
resLines.splice(curLineNum, 0, ...contents);
}

const newText: string = this.srcAsOptview.reduce((accText, curSrcLine) => {
const newText: string = resLines.reduce((accText, curSrcLine) => {
return accText + (curSrcLine.optClass === 'None' ? curSrcLine.text : ' ') + '\n';
}, '');
this.editor.setValue(newText);

const optDecorations: monaco.editor.IModelDeltaDecoration[] = [];
this.srcAsOptview.forEach((line, lineNum) => {
resLines.forEach((line, lineNum) => {
if (line.optClass !== 'None') {
optDecorations.push({
range: new monaco.Range(lineNum + 1, 1, lineNum + 1, Infinity),
Expand Down

0 comments on commit 9f5906a

Please sign in to comment.