From 377e9ab717034301dda53265d6cbf99244b70e31 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Thu, 29 Feb 2024 23:29:23 +0200 Subject: [PATCH] buffer: Fix bug. Improves responsiveness and accuracy when invoking the set-url command. Fixes #3349. See commit 36589e3d622c510df40baf6e4fd8b0bffa644a71. --- source/buffer.lisp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/source/buffer.lisp b/source/buffer.lisp index b5423896f3e..3177ce27882 100644 --- a/source/buffer.lisp +++ b/source/buffer.lisp @@ -1733,9 +1733,12 @@ Otherwise, set `engine' to `default-search-engine'.")) ;; First check engine: if set, no need to change anything. nil) ((valid-url-p (query query) - :check-dns-p check-dns-p) + :check-dns-p nil) ;; Valid URLs should be passed forward. nil) + ((and check-dns-p + (valid-tld-p (query query))) + (setf (query query) (str:concat "https://" (query query)))) ;; Rest is for invalid URLs: ((uiop:file-exists-p (query query)) (setf (query query) @@ -1744,11 +1747,6 @@ Otherwise, set `engine' to `default-search-engine'.")) (uiop:native-namestring (uiop:ensure-absolute-pathname (query query) *default-pathname-defaults*))))) - ((and check-dns-p - (valid-url-p (str:concat "https://" (query query)) - :check-dns-p check-dns-p)) - (setf (query query) - (str:concat "https://" (query query)))) (t (setf (engine query) (or (engine query) @@ -1844,7 +1842,14 @@ Otherwise, set `engine' to `default-search-engine'.")) (prompter:filter-preprocessor (lambda (suggestions source input) (declare (ignore suggestions source)) - (input->queries input :check-dns-p nil :engine-completion-p t))) + (input->queries input :check-dns-p t :engine-completion-p nil))) + (prompter:filter-postprocessor + (lambda (suggestions source input) + (declare (ignore source)) + ;; Avoid long computations until the user has finished the query. + (sleep 0.15) + (append suggestions + (input->queries input :check-dns-p nil :engine-completion-p t)))) (prompter:filter nil) (prompter:actions-on-return #'buffer-load*)) (:export-class-name-p t)