Skip to content

Commit 0bd5e52

Browse files
committed
Clean characters
1 parent d4c889c commit 0bd5e52

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ui/arduino/store.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ function store(state, emitter) {
142142
emitter.on('save', async () => {
143143
log('save')
144144
let editor = state.cache(AceEditor, 'editor').editor
145-
let contents = editor.getValue()
145+
let contents = cleanCharacters(editor.getValue())
146+
editor.setValue(contents)
146147
let filename = state.selectedFile || 'undefined'
147148
let deviceName = state.selectedDevice === 'serial' ? 'board' : 'disk'
148149

@@ -229,7 +230,7 @@ function store(state, emitter) {
229230
}
230231

231232
let editor = state.cache(AceEditor, 'editor').editor
232-
editor.setValue(content)
233+
editor.setValue(cleanCharacters(content))
233234

234235
state.blocking = false
235236
emitter.emit('render')
@@ -431,7 +432,8 @@ function store(state, emitter) {
431432
let deviceName = state.selectedDevice === 'serial' ? 'board' : 'disk'
432433

433434
let editor = state.cache(AceEditor, 'editor').editor
434-
let contents = editor.getValue()
435+
let contents = cleanCharacters(editor.getValue())
436+
editor.setValue(contents)
435437

436438
if (state.selectedDevice === 'serial') {
437439
// Ask for confirmation to overwrite existing file
@@ -569,3 +571,7 @@ function resizeEditor(state) {
569571
function cleanPath(path) {
570572
return '/' + path.split('/').filter(f => f).join('/')
571573
}
574+
575+
function cleanCharacters(str) {
576+
return str.replace(/[\u{0080}-\u{FFFF}]/gu,"")
577+
}

0 commit comments

Comments
 (0)