diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 18ded67061..a478b592cd 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -32,7 +32,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { }) const [currentVersion, setCurrentVersion] = useState('') const [hideWarnings, setHideWarnings] = useState(false) - const [compileErrors, setCompileErrors] = useState(api.compileErrors) + const [compileErrors, setCompileErrors] = useState>({ [currentFile]: api.compileErrors }) useEffect(() => { (async () => { @@ -64,19 +64,18 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { setState(prevState => { return { ...prevState, currentFile: '' } }) - setCompileErrors({} as CompileErrors) + setCompileErrors({} as Record) } api.onCompilationFinished = (contractsDetails: any, contractMap: any) => { setState(prevState => { return { ...prevState, contractsDetails, contractMap } }) - setCompileErrors(api.compileErrors) + setCompileErrors({ ...compileErrors, [currentFile]: api.compileErrors }) } api.onFileClosed = (name) => { - console.log('path/name: ', name, currentFile) - if (name === currentFile) setCompileErrors({} as CompileErrors) + if (name === currentFile) setCompileErrors({ ...compileErrors, [currentFile]: {} as CompileErrors }) } const toast = (message: string) => { @@ -129,20 +128,22 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
-
- - { compileErrors.error && } - { compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) } - { compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => { - if (hideWarnings) { - if (err.severity !== 'warning') { + { compileErrors[currentFile] && +
+ + { compileErrors[currentFile].error && } + { compileErrors[currentFile].error && (compileErrors[currentFile].error.mode === 'panic') && modal('Error', panicMessage(compileErrors[currentFile].error.formattedMessage), 'Close', null) } + { compileErrors[currentFile].errors && compileErrors[currentFile].errors.length && compileErrors[currentFile].errors.map((err, index) => { + if (hideWarnings) { + if (err.severity !== 'warning') { + return + } + } else { return } - } else { - return - } - }) } -
+ }) } +
+ }