use shortkey only if sol file

pull/2462/head
yann300 2 years ago
parent 29a821b3b1
commit 1fdbcf9dda
  1. 8
      apps/solidity-compiler/src/app/compiler-api.ts
  2. 8
      libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts

@ -332,9 +332,11 @@ export const CompilerApiMixin = (Base) => class extends Base {
// ctrl+s or command+s // ctrl+s or command+s
if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.keyCode === 83 && this.currentFile !== '') { if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.keyCode === 83 && this.currentFile !== '') {
e.preventDefault() e.preventDefault()
if(await this.getAppParameter('hardhat-compilation')) this.compileTabLogic.runCompiler('hardhat') if (this.currentFile && (this.currentFile.endsWith('.sol') || this.currentFile.endsWith('.yul'))) {
else if(await this.getAppParameter('truffle-compilation')) this.compileTabLogic.runCompiler('truffle') if(await this.getAppParameter('hardhat-compilation')) this.compileTabLogic.runCompiler('hardhat')
else this.compileTabLogic.runCompiler(undefined) else if(await this.getAppParameter('truffle-compilation')) this.compileTabLogic.runCompiler('truffle')
else this.compileTabLogic.runCompiler(undefined)
}
} }
} }
window.document.addEventListener('keydown', this.data.eventHandlers.onKeyDown) window.document.addEventListener('keydown', this.data.eventHandlers.onKeyDown)

@ -131,11 +131,6 @@ export class CompileTabLogic {
runCompiler (externalCompType) { runCompiler (externalCompType) {
try { try {
const currentFile = this.api.currentFile
if (currentFile && (currentFile.endsWith('.ts') || currentFile.endsWith('.js') || currentFile.endsWith('.txt') || currentFile.endsWith('.log'))) {
// these are obviously not solidity files.
return
}
if (this.api.getFileManagerMode() === 'localhost') { if (this.api.getFileManagerMode() === 'localhost') {
if (externalCompType === 'hardhat') { if (externalCompType === 'hardhat') {
const { currentVersion, optimize, runs } = this.compiler.state const { currentVersion, optimize, runs } = this.compiler.state
@ -188,7 +183,8 @@ export class CompileTabLogic {
} }
} }
// TODO readd saving current file // TODO readd saving current file
this.api.saveCurrentFile() this.api.saveCurrentFile()
const currentFile = this.api.currentFile
return this.compileFile(currentFile) return this.compileFile(currentFile)
} catch (err) { } catch (err) {
console.error(err) console.error(err)

Loading…
Cancel
Save