Skip to content

Commit

Permalink
Merge pull request #660 from ahmed-shariff/master
Browse files Browse the repository at this point in the history
Fix for rename-file-advisor renaming current file accidentally
  • Loading branch information
manateelazycat committed Jun 23, 2023
2 parents 8d19439 + 57f80a0 commit af68799
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lsp-bridge.el
Original file line number Diff line number Diff line change
Expand Up @@ -2066,9 +2066,14 @@ SymbolKind (defined in the LSP)."
(evil-add-command-properties #'lsp-bridge-find-impl :jump t))

(defun lsp-bridge--rename-file-advisor (orig-fun &optional arg &rest args)
(when (and lsp-bridge-mode
(boundp 'acm-backend-lsp-filepath))
(let ((new-name (expand-file-name (nth 0 args))))
(let* ((current-file-name (buffer-file-name))
(current-file-name (and current-file-name
(expand-file-name current-file-name)))
(new-name (expand-file-name (nth 0 args))))
(when (and lsp-bridge-mode
(boundp 'acm-backend-lsp-filepath)
current-file-name
(string-equal current-file-name new-name))
(lsp-bridge-call-file-api "rename_file" new-name)
(if (lsp-bridge-is-remote-file)
(lsp-bridge-remote-send-func-request "close_file" (list acm-backend-lsp-filepath))
Expand Down

0 comments on commit af68799

Please sign in to comment.