commit
0e2e8687a7
1 changed files with 9 additions and 1 deletions
|
|
@ -39,7 +39,6 @@ let history = (function () {
|
||||||
history[history.length-1] = input;
|
history[history.length-1] = input;
|
||||||
history[history.length] = "";
|
history[history.length] = "";
|
||||||
}
|
}
|
||||||
historyPos = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
|
|
@ -49,6 +48,7 @@ let history = (function () {
|
||||||
var onKeydown = function(event) {
|
var onKeydown = function(event) {
|
||||||
var code = event.which;
|
var code = event.which;
|
||||||
var historyEntry = null;
|
var historyEntry = null;
|
||||||
|
var startingPos = historyPos;
|
||||||
|
|
||||||
// Only process up/down arrow if cursor is at the end of the line.
|
// Only process up/down arrow if cursor is at the end of the line.
|
||||||
if (code === 38 && event.shiftKey) { // Shift + Arrow up
|
if (code === 38 && event.shiftKey) { // Shift + Arrow up
|
||||||
|
|
@ -69,6 +69,13 @@ let history = (function () {
|
||||||
if( inputfield.length < 1 ) { // pre-goldenlayout backwards compatibility
|
if( inputfield.length < 1 ) { // pre-goldenlayout backwards compatibility
|
||||||
inputfield = $("#inputfield");
|
inputfield = $("#inputfield");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// store any partially typed line as a new history item before replacement
|
||||||
|
var line = inputfield.val();
|
||||||
|
if( line !== "" && startingPos === 0 ) {
|
||||||
|
add(line);
|
||||||
|
}
|
||||||
|
|
||||||
inputfield.val("");
|
inputfield.val("");
|
||||||
inputfield.blur().focus().val(historyEntry);
|
inputfield.blur().focus().val(historyEntry);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
@ -82,6 +89,7 @@ let history = (function () {
|
||||||
// Listen for onSend lines to add to history
|
// Listen for onSend lines to add to history
|
||||||
var onSend = function (line) {
|
var onSend = function (line) {
|
||||||
add(line);
|
add(line);
|
||||||
|
historyPos = 0;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue