1
0
Fork 0

- [gui] prevented creating a new file with editor

when a string not representing an absolute IRI, or an existing path in a local file system was  typed on the address bar, the program tried to open it with an external program (example, starting an editor) instead of trigger a search on the gemspace.
This commit is contained in:
cage 2024-09-21 17:20:43 +02:00
parent 759fc15125
commit dcda3f91ad
1 changed files with 11 additions and 10 deletions

View File

@ -1023,6 +1023,14 @@ local file paths."
:font (gui-conf:gemini-preformatted-text-font-configuration))
(set-text-gemtext main-window lines)))
(defun ask-for-search (criteria main-window)
(when (gui:ask-yesno (format nil
(_ "No such file or directory: ~s, search gemspace instead?")
criteria)
:title (_ "Question")
:parent main-window)
(open-search-iri criteria main-window)))
(defun open-local-path (path main-window &key (force-rendering nil))
(cond
((fs:file-exists-p path)
@ -1056,11 +1064,7 @@ local file paths."
(set-address-bar-text main-window file-path)
(open-local-path file-path main-window)))
(t
(when (gui:ask-yesno (format nil (_ "No such file or directory: ~s, search gemspace instead?")
path)
:title (_ "Error")
:parent main-window)
(open-search-iri path main-window)))))
(ask-for-search path main-window))))
(defun render-gemtext-string (main-window parsed-lines &key (links-path-prefix ""))
(ev:with-enqueued-process-and-unblock ()
@ -1178,13 +1182,10 @@ local file paths."
(initialize-ir-lines main-window)
(open-local-path (iri:path parsed-iri) main-window))
(t
(client-os-utils:open-resource-with-external-program main-window actual-iri))))
(ask-for-search iri main-window))))
(esrap:esrap-parse-error (e)
(declare (ignore e))
(when (gui:ask-yesno (_ "Invalid address, perform a search using your input?")
:title (_ "Invalid address")
:parent main-window)
(open-search-iri iri main-window)))
(ask-for-search iri main-window))
(error (e)
(gui-goodies:notify-request-error e))))