diff --git a/src/command-window.lisp b/src/command-window.lisp index 05ed77d..d71fae7 100644 --- a/src/command-window.lisp +++ b/src/command-window.lisp @@ -434,8 +434,7 @@ be either `:keybinding' or `:string'. the former for key command the latter for (column (elt columns selected-item-column-index)) (suggestion (trim-blanks (elt column selected-item-row-index)))) (setf command-line suggestion) - (move-point-to-end win command-line) - (win-hide suggestions-win)))))) + (move-point-to-end win command-line)))))) (defun fire-user-input-event (win) "Generates an event to notify that the user inserted an input on the @@ -478,12 +477,6 @@ command line." (move-suggestion-page-left command-window)) ((eq :alt-right event) (move-suggestion-page-right command-window)) - ((eq :alt-up event) - (select-suggestion-next command-window)) - ((eq :alt-down event) - (select-suggestion-previous command-window)) - ((eq :alt-i event) - (insert-selected-suggestion command-window)) ((eq :backspace event) (setf command-line (delete-at-point command-window command-line :direction :left)) (show-candidate-completion command-window)) @@ -499,13 +492,17 @@ command line." ((eq :home event) (move-point-to-start command-window)) ((eq :up event) - (multiple-value-bind (new-id new-input) - (db:previous-in-history history-position prompt) - (set-history new-id new-input))) + (if (win-shown-p suggestions-win) + (select-suggestion-next command-window) + (multiple-value-bind (new-id new-input) + (db:previous-in-history history-position prompt) + (set-history new-id new-input)))) ((eq :down event) - (multiple-value-bind (new-id new-input) - (db:next-in-history history-position prompt) - (set-history new-id new-input))) + (if (win-shown-p suggestions-win) + (select-suggestion-previous command-window) + (multiple-value-bind (new-id new-input) + (db:next-in-history history-position prompt) + (set-history new-id new-input)))) ((characterp event) (cond ((char= #\Newline event) @@ -515,7 +512,7 @@ command line." (move-point-to-start command-window) (set-keybinding-mode command-window)) ((char= #\Tab event) - (complete-at-point command-window)) + (insert-selected-suggestion command-window)) (t (when (null suggestions-win) (setf suggestions-win (complete-window:init))) diff --git a/src/complete.lisp b/src/complete.lisp index 78be555..b46d5b1 100644 --- a/src/complete.lisp +++ b/src/complete.lisp @@ -199,13 +199,13 @@ list af all possible candidtae for completion." (let ((strings '()) (indices '()) (ordering ())) - (loop for candidate in bag when (< (length template) - (length candidate)) + (loop for candidate in bag when (<= (length template) + (length candidate)) do (when-let ((indices-matched (cl-i18n-utils:fuzzy-match template candidate :similarity-match 5 :similarity-mismatch -5 - :penalty-weight 1 ))) + :penalty-weight 1))) (push candidate strings) (push indices-matched indices))) (setf ordering (loop for i from 0 below (length strings) collect i)) diff --git a/src/text-utils.lisp b/src/text-utils.lisp index 9e33563..9ba9edc 100644 --- a/src/text-utils.lisp +++ b/src/text-utils.lisp @@ -128,7 +128,9 @@ (advance-res) (%advance)))) (%advance) - res)))) + (if (= prefix-count 0) + nil + res))))) (defgeneric join-with-strings (object junction))