mpy/alerts: implement compiler error

This shows the output from mpy-cross and has a button to go to the
error.
This commit is contained in:
David Lechner
2022-10-19 18:26:37 -05:00
committed by David Lechner
parent e5ab52b250
commit 7e726fffaf
10 changed files with 159 additions and 0 deletions
+9
View File
@@ -112,3 +112,12 @@ export const editorDidFailToActivateFile = createAction((uuid: UUID, error: Erro
uuid,
error,
}));
/**
* Requests to activate a file and show line.
*/
export const editorGoto = createAction((uuid: UUID, line: number) => ({
type: 'editor.action.goto',
uuid,
line,
}));
+30
View File
@@ -60,6 +60,7 @@ import {
editorDidOpenFile,
editorGetValueRequest,
editorGetValueResponse,
editorGoto,
editorOpenFile,
} from './actions';
import { EditorError } from './error';
@@ -265,6 +266,34 @@ function* handleEditorActivateFile(
}
}
function* handleEditorGoto(
editor: monaco.editor.ICodeEditor,
action: ReturnType<typeof editorGoto>,
): Generator {
yield* put(editorActivateFile(action.uuid));
const { didActivate, didFailToActivate } = yield* race({
didActivate: take(editorDidActivateFile.when((a) => a.uuid === action.uuid)),
didFailToActivate: take(
editorDidFailToActivateFile.when((a) => a.uuid === action.uuid),
),
});
if (didFailToActivate) {
return;
}
defined(didActivate);
editor.revealLineInCenterIfOutsideViewport(action.line);
editor.setSelection({
startColumn: 1,
startLineNumber: action.line,
endColumn: Infinity,
endLineNumber: action.line,
});
}
function* handleEditorDidCloseFile(
activeFileHistory: ActiveFileHistoryManager,
action: ReturnType<typeof editorDidCloseFile>,
@@ -356,6 +385,7 @@ function* handleDidCreateEditor(editor: monaco.editor.ICodeEditor): Generator {
openFiles,
activeFileHistory,
);
yield* takeEvery(editorGoto, handleEditorGoto, editor);
yield* takeEvery(editorDidCloseFile, handleEditorDidCloseFile, activeFileHistory);
yield* fork(monitorViewState, editor);