Skip to content

Bugfix/clean repl before actions #55

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

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const Serial = {
},
stop: async () => {
await board.stop()
return Promise.resolve()
},
exit_raw_repl: async () => {
await board.exit_raw_repl()
return Promise.resolve()
},
Expand Down Expand Up @@ -70,9 +73,6 @@ const Serial = {
createFolder: async (folder) => {
return await board.fs_mkdir(folder)
},
exit_raw_repl: async () => {
return board.exit_raw_repl()
},
getNavigationPath: (navigation, target) => {
return [navigation, target].filter(p => p).join('/')
},
Expand Down
7 changes: 7 additions & 0 deletions ui/arduino/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ function store(state, emitter) {
if (!state.isTerminalOpen) emitter.emit('show-terminal')
let editor = state.cache(AceEditor, 'editor').editor
let code = editor.getValue()
await serial.stop()
await serial.run(code)
emitter.emit('render')
})
emitter.on('stop', async () => {
log('stop')
await serial.stop()
await serial.exit_raw_repl()
emitter.emit('render')
})
emitter.on('reset', async () => {
Expand Down Expand Up @@ -173,6 +175,7 @@ function store(state, emitter) {
emitter.emit('message', `Saving ${filename} on ${deviceName}.`)

if (state.selectedDevice === 'serial') {
await serial.stop()
await serial.saveFileContent(
serial.getFullPath(
state.serialPath,
Expand Down Expand Up @@ -213,6 +216,7 @@ function store(state, emitter) {

if (confirm(`Do you want to remove ${state.selectedFile} from ${deviceName}?`)) {
if (state.selectedDevice === 'serial') {
await serial.stop()
await serial.removeFile(state.serialNavigation + '/' + state.selectedFile)
emitter.emit('new-file', 'serial')
}
Expand Down Expand Up @@ -253,6 +257,7 @@ function store(state, emitter) {

let content = ''
if (state.selectedDevice === 'serial') {
await serial.stop()
content = await serial.loadFile(
serial.getFullPath(
state.serialPath,
Expand Down Expand Up @@ -417,6 +422,7 @@ function store(state, emitter) {
let contents = cleanCharacters(editor.getValue())
editor.setValue(contents)
if (state.unsavedChanges) {
await serial.stop()
await serial.saveFileContent(
serial.getFullPath(
state.serialPath,
Expand Down Expand Up @@ -527,6 +533,7 @@ function store(state, emitter) {
editor.setValue(contents)

if (state.isConnected && state.selectedDevice === 'serial') {
await serial.stop()
// Ask for confirmation to overwrite existing file
let confirmation = true
if (state.serialFiles.find(f => f.path === filename)) {
Expand Down