Skip to content

Commit

Permalink
Supports obtaining paths with spaces (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcq062821 authored Jan 26, 2024
1 parent ec33ddd commit fec7592
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,8 @@ So we build this macro to restore postion after code format."
(lsp-bridge-string-interpolation-p lsp-bridge-string-interpolation-open-chars-alist)
;; Allow file path completion in string area
(ignore-errors
(and (thing-at-point 'filename)
(or (file-exists-p (file-name-directory (thing-at-point 'filename)))
(and (lsp-bridge-elisp-get-filepath)
(or (file-exists-p (file-name-directory (lsp-bridge-elisp-get-filepath)))
;; Allow string in lsp-bridge-remote file.
(lsp-bridge-is-remote-file))))))

Expand Down Expand Up @@ -1578,7 +1578,7 @@ So we build this macro to restore postion after code format."

;; Send path search request when detect path string.
(if (acm-in-string-p)
(when-let* ((filename (thing-at-point 'filename t))
(when-let* ((filename (lsp-bridge-elisp-get-filepath))
(dirname (ignore-errors (expand-file-name (file-name-directory filename)))))
(if (lsp-bridge-is-remote-file)
(let ((path (if (tramp-tramp-file-p dirname)
Expand All @@ -1596,6 +1596,25 @@ So we build this macro to restore postion after code format."
;; Otherwise, other completion backend won't show up.
(setq-local acm-backend-path-items nil))))

(defun lsp-bridge-elisp-get-filepath ()
" Supports obtaining paths with spaces "
(let* ((file-end (point))
(filepath (save-excursion
(catch 'break
(let* ((file-path "")
(file-beg 0))
(while (acm-in-string-p)
(setq file-beg (car (bounds-of-thing-at-point 'filename)))
(if file-beg
(progn
(setq file-path (buffer-substring file-beg file-end))
(if (and (file-name-directory file-path) (file-exists-p (file-name-directory file-path)))
(progn
(throw 'break file-path))
(goto-char (1- file-beg))))
(throw 'break nil))))))))
filepath))

(defun lsp-bridge-elisp-symbols-update ()
"We need synchronize elisp symbols to Python side when idle."
(when (lsp-bridge-process-live-p)
Expand Down

0 comments on commit fec7592

Please sign in to comment.