Skip to content

Commit c5d6276

Browse files
committed
#12 - instance undo with backspace. This closed #12
1 parent 67508fb commit c5d6276

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/common/vpInstanceEditor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ define([
288288
});
289289
}
290290
}
291-
292291
});
293292
}
294293

src/file_io/instance.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,18 @@ define([
235235
that.reloadInsEditor();
236236
});
237237

238+
// backspace
239+
$(document).on('keyup', this.wrapSelector('.CodeMirror'), function(event) {
240+
var keycode = event.keyCode
241+
? event.keyCode
242+
: event.which;
243+
if (keycode == 8) {
244+
// backspace
245+
that.popStack();
246+
that.reloadInsEditor();
247+
}
248+
});
249+
238250
// subset button clicked
239251
$(document).on('click', this.wrapSelector('.vp-ds-button'), function(event) {
240252
var insEditorType = $(this).closest('.vp-instance-box').hasClass('variable')? 'variable': 'allocate';
@@ -369,11 +381,10 @@ define([
369381
}
370382

371383
VariablePackage.prototype.popStack = function(replace=true) {
372-
if (this.pointer.stack.length <= 0) {
373-
return '';
374-
}
375-
376384
var lastValue = this.pointer.stack.pop();
385+
if (!lastValue) {
386+
lastValue = '';
387+
}
377388
if (replace) {
378389
this.updateValue('', lastValue);
379390
}

0 commit comments

Comments
 (0)