Skip to content

Commit c6066fd

Browse files
authored
Merge pull request #55 from arduino/bugfix/clean-repl-before-actions
Bugfix/clean repl before actions
2 parents 13969a1 + b70a767 commit c6066fd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

preload.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const Serial = {
2323
},
2424
stop: async () => {
2525
await board.stop()
26+
return Promise.resolve()
27+
},
28+
exit_raw_repl: async () => {
2629
await board.exit_raw_repl()
2730
return Promise.resolve()
2831
},
@@ -70,9 +73,6 @@ const Serial = {
7073
createFolder: async (folder) => {
7174
return await board.fs_mkdir(folder)
7275
},
73-
exit_raw_repl: async () => {
74-
return board.exit_raw_repl()
75-
},
7676
getNavigationPath: (navigation, target) => {
7777
return path.posix.join(navigation, target)
7878
},

ui/arduino/store.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,14 @@ function store(state, emitter) {
135135
if (!state.isTerminalOpen) emitter.emit('show-terminal')
136136
let editor = state.cache(AceEditor, 'editor').editor
137137
let code = editor.getValue()
138+
await serial.stop()
138139
await serial.run(code)
139140
emitter.emit('render')
140141
})
141142
emitter.on('stop', async () => {
142143
log('stop')
143144
await serial.stop()
145+
await serial.exit_raw_repl()
144146
emitter.emit('render')
145147
})
146148
emitter.on('reset', async () => {
@@ -173,6 +175,7 @@ function store(state, emitter) {
173175
emitter.emit('message', `Saving ${filename} on ${deviceName}.`)
174176

175177
if (state.selectedDevice === 'serial') {
178+
await serial.stop()
176179
await serial.saveFileContent(
177180
serial.getFullPath(
178181
state.serialPath,
@@ -213,6 +216,7 @@ function store(state, emitter) {
213216

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

254258
let content = ''
255259
if (state.selectedDevice === 'serial') {
260+
await serial.stop()
256261
content = await serial.loadFile(
257262
serial.getFullPath(
258263
state.serialPath,
@@ -417,6 +422,7 @@ function store(state, emitter) {
417422
let contents = cleanCharacters(editor.getValue())
418423
editor.setValue(contents)
419424
if (state.unsavedChanges) {
425+
await serial.stop()
420426
await serial.saveFileContent(
421427
serial.getFullPath(
422428
state.serialPath,
@@ -527,6 +533,7 @@ function store(state, emitter) {
527533
editor.setValue(contents)
528534

529535
if (state.isConnected && state.selectedDevice === 'serial') {
536+
await serial.stop()
530537
// Ask for confirmation to overwrite existing file
531538
let confirmation = true
532539
if (state.serialFiles.find(f => f.path === filename)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy