Skip to content

Commit 3780c49

Browse files
committed
Skip downloading from board if there are no unsaved changes
1 parent 0e55213 commit 3780c49

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

ui/arduino/store.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -417,26 +417,27 @@ function store(state, emitter) {
417417
let editor = state.cache(AceEditor, 'editor').editor
418418
let contents = cleanCharacters(editor.getValue())
419419
editor.setValue(contents)
420-
await serial.saveFileContent(
421-
serial.getFullPath(
422-
state.serialPath,
423-
state.serialNavigation,
424-
state.selectedFile
425-
),
426-
contents
427-
)
428-
await serial.downloadFile(
429-
serial.getFullPath(
430-
state.serialPath,
431-
state.serialNavigation,
432-
state.selectedFile
433-
),
420+
if (state.unsavedChanges) {
421+
await serial.saveFileContent(
422+
serial.getFullPath(
423+
state.serialPath,
424+
state.serialNavigation,
425+
state.selectedFile
426+
),
427+
contents,
428+
(e) => emitter.emit('message', `Saving ${state.selectedFile} on ${getDeviceName('serial')}. ${e}`)
429+
)
430+
state.unsavedChanges = false
431+
}
432+
await disk.saveFileContent(
434433
disk.getFullPath(
435434
state.diskPath,
436435
state.diskNavigation,
437436
state.selectedFile
438-
)
437+
),
438+
contents
439439
)
440+
440441
emitter.emit('message', 'File downloaded!', 500)
441442
setTimeout(() => emitter.emit('update-files'), 500)
442443
emitter.emit('render')

0 commit comments

Comments
 (0)