Skip to content

Commit

Permalink
Fix issue #1126, use lsp-bridge-path-equal instead string-equal, avoi…
Browse files Browse the repository at this point in the history
…d path missmatch by Windows case.
  • Loading branch information
manateelazycat committed Dec 15, 2024
1 parent 520d253 commit 2031e6d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lsp-bridge-call-hierarchy.el
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
(found-buffer))

(if (dolist (buffer (buffer-list) found-buffer)
(when (string-equal (buffer-file-name buffer) path)
(when (lsp-bridge-path-equal (buffer-file-name buffer) path)
(setq found-buffer buffer)))
(find-file path)
(add-to-list 'lsp-bridge-call-hierarchy--temp-buffers (find-file path)))
Expand Down
2 changes: 1 addition & 1 deletion lsp-bridge-inlay-hint.el
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
If lsp-bridge detect this error, lsp-bridge will call `lsp-bridge-inlay-hint-retry' function again to avoid inlayHint request no respond."
(when (string-prefix-p "file://" filepath)
(setq filepath (string-remove-prefix "file://" filepath)))
(when (string-equal filepath (buffer-file-name))
(when (lsp-bridge-path-equal filepath (buffer-file-name))
(lsp-bridge-inlay-hint-try-send-request)))

(provide 'lsp-bridge-inlay-hint)
Expand Down
2 changes: 1 addition & 1 deletion lsp-bridge-jdtls.el
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ E.g. Use `-javaagent:/home/user/.emacs.d/plugin/lombok.jar` to add lombok suppor

(defun lsp-bridge-jdtls-single-file-mode? (project-path filepath)
"Determine whether it is a single file mode?"
(string-equal project-path filepath))
(lsp-bridge-path-equal project-path filepath))

(dolist (hook (list
'java-mode-hook
Expand Down
2 changes: 1 addition & 1 deletion lsp-bridge-ref.el
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ user more freedom to use rg with special arguments."
(cl-dolist (buffer (buffer-list))
(let* ((buf-file-name (buffer-file-name buffer))
(file-name (if (stringp buf-file-name) (substring-no-properties buf-file-name) buf-file-name)))
(when (string-equal file-name filepath)
(when (lsp-bridge-path-equal file-name filepath)
(cl-return buffer)
))))

Expand Down
21 changes: 13 additions & 8 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ you can customize `lsp-bridge-get-workspace-folder' to return workspace folder p
(erlang-mode . erlang-indent-level) ; Erlang
(ada-mode . ada-indent) ; Ada
(scad-mode . lsp-bridge-indent-two-level) ; OpenSCAD
(sml-mode . sml-indent-level) ; Standard ML
(sml-mode . sml-indent-level) ; Standard ML
(fuzion-mode . lsp-bridge-indent-two-level) ; Fuzion
(fennel-mode . lsp-bridge-indent-two-level) ; Fennel
(ttcn3-mode . lsp-bridge-indent-four-level) ; TTCN3
Expand Down Expand Up @@ -925,8 +925,8 @@ you can customize `lsp-bridge-get-workspace-folder' to return workspace folder p
"Evaluate BODY in buffer with FILEPATH."
(declare (indent 1))
`(when-let* ((buffer (pcase ,filehost
("" (lsp-bridge-get-match-buffer-by-filepath ,filename))
(_ (lsp-bridge-get-match-buffer-by-remote-file ,filehost ,filename)))))
("" (lsp-bridge-get-match-buffer-by-filepath ,filename))
(_ (lsp-bridge-get-match-buffer-by-remote-file ,filehost ,filename)))))
(with-current-buffer buffer
,@body)))

Expand Down Expand Up @@ -969,7 +969,7 @@ So we build this macro to restore postion after code format."
(cl-dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (and (boundp 'lsp-bridge-remote-file-path)
(string-equal lsp-bridge-remote-file-path path)
(lsp-bridge-path-equal lsp-bridge-remote-file-path path)
(boundp 'lsp-bridge-remote-file-host)
(or (string-equal lsp-bridge-remote-file-host host)
;; host is "127.0.0.1" sent from get_lsp_file_host() when server running inside container
Expand All @@ -981,10 +981,15 @@ So we build this macro to restore postion after code format."
(cl-dolist (buffer (buffer-list))
(with-current-buffer buffer
(when-let* ((file-name (buffer-file-name buffer))
(match-buffer (or (string-equal file-name name)
(string-equal (file-truename file-name) name))))
(match-buffer (or (lsp-bridge-path-equal file-name name)
(lsp-bridge-path-equal (file-truename file-name) name))))
(cl-return buffer)))))

(defun lsp-bridge-path-equal (path-a path-b)
(cond ((memq system-type '(cygwin windows-nt ms-dos))
(string-equal (downcase path-a) (downcase path-b)))
(t (string-equal path-a path-b))))

(defun lsp-bridge--get-project-path-func (filename)
"Get project root path, search order:
Expand Down Expand Up @@ -1484,7 +1489,7 @@ So we build this macro to restore postion after code format."
(save-excursion
(goto-char (point-max))
(insert (format "\n*** %s execute predicate '%s' failed with result: '%s'\n"
current-function pred result))))))
current-function pred result))))))
result)
(error
(message "Error in predicate '%s': %S at point %S in buffer %S, mode %S"
Expand Down Expand Up @@ -1616,7 +1621,7 @@ So we build this macro to restore postion after code format."
"Hide completion if string before cursor match some special keywords."
(let ((string (if (bounds-of-thing-at-point 'symbol)
(buffer-substring-no-properties (car (bounds-of-thing-at-point 'symbol))
(point))
(point))
(char-to-string (char-before)))))
(not (when (and (or (derived-mode-p 'ruby-mode)
(derived-mode-p 'ruby-ts-mode)
Expand Down

0 comments on commit 2031e6d

Please sign in to comment.