From d995a5e072dce02dde0ff2cd19245d28ea69f95c Mon Sep 17 00:00:00 2001 From: Brenden Tuck Date: Tue, 27 Oct 2020 22:30:32 -0400 Subject: [PATCH] Fix text save bug #2233 --- .../webclient/static/webclient/js/plugins/history.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/evennia/web/webclient/static/webclient/js/plugins/history.js b/evennia/web/webclient/static/webclient/js/plugins/history.js index 2aa6f0991f..a9a68ba6c2 100644 --- a/evennia/web/webclient/static/webclient/js/plugins/history.js +++ b/evennia/web/webclient/static/webclient/js/plugins/history.js @@ -39,7 +39,6 @@ let history = (function () { history[history.length-1] = input; history[history.length] = ""; } - historyPos = 0; } // Public @@ -49,6 +48,7 @@ let history = (function () { var onKeydown = function(event) { var code = event.which; var historyEntry = null; + var startingPos = historyPos; // Only process up/down arrow if cursor is at the end of the line. if (code === 38 && event.shiftKey) { // Shift + Arrow up @@ -69,6 +69,13 @@ let history = (function () { if( inputfield.length < 1 ) { // pre-goldenlayout backwards compatibility 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.blur().focus().val(historyEntry); event.preventDefault(); @@ -82,6 +89,7 @@ let history = (function () { // Listen for onSend lines to add to history var onSend = function (line) { add(line); + historyPos = 0; return null; }