Permalink
Browse files

Fixed history bug. (merged change over from jquery-console project)

 o commandResult calls newPromptBox which sets promptText to the empty string
 o addToHistory uses the value of promptText to push into the history array
 o thus, whenever commandResult was called before addToHistory, an empty
   string would be placed on the history array

Now, addToHistory is always called before commandResult so it pushes the
command to the history array in all cases.
  • Loading branch information...
spratt authored and chrisdone committed Jun 3, 2010
1 parent 07af4fa commit 453ce1f531582b801ffda382fe26c05dc5395247
Showing with 2 additions and 9 deletions.
  1. +2 −9 js/jquery.console.js
View
@@ -355,28 +355,21 @@
// Handle a command
function handleCommand() {
if (typeof config.commandHandle == 'function') {
- var ret = config.commandHandle(
- promptText.substr(0),
- function(msgs){
+ addToHistory(promptText);
+ var ret = config.commandHandle(promptText,function(msgs){
commandResult(msgs);
});
if (typeof ret == 'boolean') {
if (ret) {
// Command succeeded without a result.
- addToHistory(promptText);
commandResult();
} else {
- addToHistory(promptText);
commandResult('Command failed.',
"jquery-console-message-error");
}
} else if (typeof ret == "string") {
- addToHistory(promptText);
commandResult(ret,"jquery-console-message-success");
- } else if (typeof ret == 'undefined') {
- addToHistory(promptText);
} else if (ret.length) {
- addToHistory(promptText);
commandResult(ret);
}
}

0 comments on commit 453ce1f

Please sign in to comment.