Skip to content

Commit

Permalink
buffer: Fix bug.
Browse files Browse the repository at this point in the history
Fixes #3349.
  • Loading branch information
aadcg committed Feb 29, 2024
1 parent 64c52bd commit be9e87b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions source/buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,17 +1400,19 @@ If prefixing with 'https://' results in a valid URL, set `query' to it.
Otherwise, set `engine' to `default-search-engine'."))

(defmethod initialize-instance :after ((query new-url-query)
&key check-dns-p &allow-other-keys)
&key (check-dns-p nil) &allow-other-keys)
;; Trim whitespace, in particular to detect URL properly.
(setf (query query) (str:trim (query query)))
(cond
((engine query)
;; First check engine: if set, no need to change anything.
nil)
((valid-url-p (query query)
:check-dns-p check-dns-p)
((valid-url-p (query query) :check-dns-p check-dns-p)
;; Valid URLs should be passed forward.
nil)
((ignore-errors (cl-tld:get-tld (query query)))
(setf (query query)
(str:concat "https://" (query query))))
;; Rest is for invalid URLs:
((uiop:file-exists-p (query query))
(setf (query query)
Expand All @@ -1419,11 +1421,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)
Expand Down Expand Up @@ -1464,7 +1461,7 @@ Otherwise, set `engine' to `default-search-engine'."))
:query (second completion)
:label (first completion)))))

(defun input->queries (input &key (check-dns-p t) (engine-completion-p))
(defun input->queries (input &key (check-dns-p nil) (engine-completion-p t))
(let* ((terms (sera:tokens input))
(engines (let ((all-prefixed-engines
(remove-if
Expand Down Expand Up @@ -1519,7 +1516,7 @@ 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)))
(prompter:filter nil)
(prompter:actions-on-return #'buffer-load*))
(:export-class-name-p t)
Expand Down

0 comments on commit be9e87b

Please sign in to comment.