diff options
author | mongo <mongo@iomega> | 2017-02-10 16:56:48 -0300 |
---|---|---|
committer | mongo <mongo@iomega> | 2017-02-10 16:56:48 -0300 |
commit | 3abad0ba89d9d01eb8ff7195d02cf3e0c461cb19 (patch) | |
tree | a8adee876bdd8bc4f5b21ff75e3d615bb77b2e2a | |
parent | d7b3561968aa52b3674eb187d25e5979d4e94f7d (diff) |
Fix bug that create duplicates in commandline history if the command recently typed was the latest used as well
-rw-r--r-- | src/cmds_command.c | 41 | ||||
-rw-r--r-- | src/history.c | 2 |
2 files changed, 21 insertions, 22 deletions
diff --git a/src/cmds_command.c b/src/cmds_command.c index 734ccdc..5fbc60c 100644 --- a/src/cmds_command.c +++ b/src/cmds_command.c @@ -299,24 +299,22 @@ void do_commandmode(struct block * sb) { return; - - //------------------------------------- // CONFIRM A COMMAND PRESSING ENTER //------------------------------------- } else if (find_val(sb, OKEY_ENTER)) { - if ( ! wcscmp(inputline, L"q") || ! wcscmp(inputline, L"quit") ) { - shall_quit = 1; - - } else if ( ! wcscmp(inputline, L"refresh")) { + if ( ! wcscmp(inputline, L"refresh")) { winchg(); + } else if ( ! wcscmp(inputline, L"help") || ! wcscmp(inputline, L"h") ) { + help(); + } else if ( ! wcscmp(inputline, L"q!") || ! wcscmp(inputline, L"quit!") ) { shall_quit = 2; - } else if ( ! wcscmp(inputline, L"help") || ! wcscmp(inputline, L"h") ) { - help(); + } else if ( ! wcscmp(inputline, L"q") || ! wcscmp(inputline, L"quit") ) { + shall_quit = 1; } else if ( ! wcsncmp(inputline, L"autojus", 7) ) { wchar_t cline [BUFFERSIZE]; @@ -361,7 +359,7 @@ void do_commandmode(struct block * sb) { readfile(p.we_wordv[0], 0); //EvalAll(); // is it necessary? modflg = 0; - update(TRUE); + //update(TRUE); } wordfree(&p); @@ -551,8 +549,8 @@ void do_commandmode(struct block * sb) { sc_error("Color support not compiled in"); chg_mode('.'); inputline[0] = L'\0'; - update(TRUE); - return; + //update(TRUE); + //return; #endif } else if ( ! wcsncmp(inputline, L"color ", 6) ) { @@ -565,8 +563,8 @@ void do_commandmode(struct block * sb) { sc_error("Color support not compiled in"); chg_mode('.'); inputline[0] = '\0'; - update(TRUE); - return; + //update(TRUE); + //return; #endif } else if ( ! wcsncmp(inputline, L"set ", 4) ) { @@ -667,8 +665,8 @@ void do_commandmode(struct block * sb) { sc_error("XLS import support not compiled in"); chg_mode('.'); inputline[0] = L'\0'; - update(TRUE); - return; + //update(TRUE); + //return; #endif delim = 'x'; } else if ( ! strncmp(cline, "i xlsx", 6) ) { @@ -676,8 +674,8 @@ void do_commandmode(struct block * sb) { sc_error("XLSX import support not compiled in"); chg_mode('.'); inputline[0]= L'\0'; - update(TRUE); - return; + //update(TRUE); + //return; #endif delim = 'y'; } @@ -706,16 +704,17 @@ void do_commandmode(struct block * sb) { modflg = 0; update(TRUE); } - } else { + } else { sc_error("COMMAND NOT FOUND !"); } #ifdef HISTORY_FILE - del_item_from_history(commandline_history, 0); - // si hay en historial algun item con texto igual al del comando que se ejecuta - // a partir de la posicion 2, se lo coloca al comiendo de la lista (indica que es lo mas reciente ejecutado). + // if exists in history an item with same text to the command typed + // (counting from the second position) it is moved to the beginning of list. + // (first element in list means last command executed) int moved = move_item_from_history_by_str(commandline_history, inputline, -1); if (! moved) add(commandline_history, inputline); + del_item_from_history(commandline_history, 0); commandline_history->pos = 0; #endif diff --git a/src/history.c b/src/history.c index 198bb46..8210250 100644 --- a/src/history.c +++ b/src/history.c @@ -153,7 +153,7 @@ void del_item_from_history(struct history * h, int pos) { // pos=0 first element, pos=-1 second element // returns 1 if moved, 0 otherwise. int move_item_from_history_by_str(struct history * h, wchar_t * item, int pos) { - if (h->len - 1 < -pos || ! pos || ! wcslen(item)) return 0; // Move the first element is disallowed + if (h->len - 1 < -pos || pos == 0 || ! wcslen(item)) return 0; // Move the first element is not allowed struct hlist * nl = h->list; struct hlist * n_ant = NULL; int i; |