From 75295d4486da9d400e43f4b0b3932d8a3787addc Mon Sep 17 00:00:00 2001 From: Shariff Faleel Date: Thu, 22 Jun 2023 12:05:06 -0700 Subject: [PATCH 1/2] Fix for rename-file-advisor renaming current file accidentally --- lsp-bridge.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lsp-bridge.el b/lsp-bridge.el index 8d26c618a8..277f916a64 100644 --- a/lsp-bridge.el +++ b/lsp-bridge.el @@ -2066,9 +2066,11 @@ 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 (expand-file-name (buffer-file-name))) + (new-name (expand-file-name (nth 0 args)))) + (when (and lsp-bridge-mode + (boundp 'acm-backend-lsp-filepath) + (file-equal-p 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)) From 57f80a0037e9b55576e536712318cb4c6690168d Mon Sep 17 00:00:00 2001 From: Shariff Faleel Date: Thu, 22 Jun 2023 16:09:57 -0700 Subject: [PATCH 2/2] Fix errors in processing rename-file-advisor --- lsp-bridge.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lsp-bridge.el b/lsp-bridge.el index 277f916a64..e5bf63a80a 100644 --- a/lsp-bridge.el +++ b/lsp-bridge.el @@ -2066,11 +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) - (let ((current-file-name (expand-file-name (buffer-file-name))) - (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) - (file-equal-p current-file-name new-name)) + 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))