Merge pull request #1452 from danielyxie/dev

build fix for duplicate autocomplete
This commit is contained in:
hydroflame 2021-10-09 22:59:23 -04:00 committed by GitHub
commit 684e5aca4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 20 deletions

28
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -29,8 +29,8 @@ import Box from "@mui/material/Box";
import TextField from "@mui/material/TextField"; import TextField from "@mui/material/TextField";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
import SettingsIcon from "@mui/icons-material/Settings"; import SettingsIcon from "@mui/icons-material/Settings";
import { loadThemes } from "./themes";
let symbolsLoaded = false;
let symbols: string[] = []; let symbols: string[] = [];
export function SetupTextEditor(): void { export function SetupTextEditor(): void {
const ns = NetscriptFunctions({} as WorkerScript); const ns = NetscriptFunctions({} as WorkerScript);
@ -276,6 +276,8 @@ export function Root(props: IProps): React.ReactElement {
} }
function beforeMount(monaco: any): void { function beforeMount(monaco: any): void {
if (symbolsLoaded) return;
symbolsLoaded = true;
monaco.languages.registerCompletionItemProvider("javascript", { monaco.languages.registerCompletionItemProvider("javascript", {
provideCompletionItems: () => { provideCompletionItems: () => {
const suggestions = []; const suggestions = [];
@ -292,7 +294,6 @@ export function Root(props: IProps): React.ReactElement {
}); });
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, "netscript.d.ts"); monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, "netscript.d.ts");
monaco.languages.typescript.typescriptDefaults.addExtraLib(libSource, "netscript.d.ts"); monaco.languages.typescript.typescriptDefaults.addExtraLib(libSource, "netscript.d.ts");
loadThemes(monaco);
} }
return ( return (
@ -317,7 +318,7 @@ export function Root(props: IProps): React.ReactElement {
onMount={onMount} onMount={onMount}
loading={<Typography>Loading script editor!</Typography>} loading={<Typography>Loading script editor!</Typography>}
height="90%" height="90%"
language="javascript" defaultLanguage="javascript"
defaultValue={code} defaultValue={code}
onChange={updateCode} onChange={updateCode}
theme={options.theme} theme={options.theme}