Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add back setCurrentEditor #122

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ui/src/components/MyMonaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export const MyMonaco = memo<MyMonacoProps>(function MyMonaco({
const readOnly = useStore(store, (state) => state.role === RoleType.GUEST);
const showLineNumbers = useStore(store, (state) => state.showLineNumbers);
const getPod = useStore(store, (state) => state.getPod);
const setCurrentEditor = useStore(store, (state) => state.setCurrentEditor);
const setPodContent = useStore(store, (state) => state.setPodContent);
const clearResults = useStore(store, (s) => s.clearResults);
const wsRun = useStore(store, (state) => state.wsRun);
Expand All @@ -335,8 +336,10 @@ export const MyMonaco = memo<MyMonacoProps>(function MyMonaco({
const onRun = () => {
// it's MonacoEditor's bug microsoft/monaco-editor#2947, it always triggered the last created instance
const activeId = store.getState().currentEditor;
clearResults(activeId);
wsRun(activeId);
if (activeId) {
clearResults(activeId);
wsRun(activeId);
}
};

if (lang === "racket") {
Expand Down Expand Up @@ -379,6 +382,7 @@ export const MyMonaco = memo<MyMonacoProps>(function MyMonaco({
});
editor.onDidFocusEditorText(() => {
setPodFocus(id);
setCurrentEditor(id);
});
editor.onDidContentSizeChange(updateHeight);
// FIXME clean up?
Expand Down