Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* Changelog
** Unreleased 9.0.1
* Add support for ~workspace/willRenameFiles~ and ~workspace/didRenameFiles~ when using ~vc-git-rename-file~.
* Fix documentation to show unevaluated expressions for file/directory defcustom defaults instead of machine-specific paths (see [[https://github.com/emacs-lsp/lsp-mode/issues/4924][#4924]])
* Fix invalid regex patterns in ~lsp-file-watch-ignored-directories~ causing crashes (see [[https://github.com/emacs-lsp/lsp-mode/issues/3439][#3439]])
* Fix documentation website sidebar visibility on tablet landscape screens (see [[https://github.com/emacs-lsp/lsp-mode/issues/4946][#4946]])
Expand Down
14 changes: 8 additions & 6 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
(require 'xref)
(require 'minibuffer)
(require 'help-mode)
(require 'vc-git)
(require 'lsp-protocol)

(defgroup lsp-mode nil
Expand Down Expand Up @@ -6765,9 +6766,9 @@ relied upon."
:newName ,newname))))
(lsp--apply-workspace-edit edits 'rename)))

(defun lsp--on-rename-file (old-func old-name new-name &optional ok-if-already-exists?)
"Advice around function `rename-file'.
Applies OLD-FUNC with OLD-NAME, NEW-NAME and OK-IF-ALREADY-EXISTS?.
(defun lsp--on-rename-file (old-func old-name new-name &rest args)
"Advice around file renaming functions such as `rename-file'.
Applies OLD-FUNC with OLD-NAME, NEW-NAME and remaining ARGS.

This advice sends workspace/willRenameFiles before renaming file
to check if server wants to apply any workspaceEdits after renamed."
Expand All @@ -6780,13 +6781,14 @@ to check if server wants to apply any workspaceEdits after renamed."
(if-let* ((edits (lsp-request "workspace/willRenameFiles" params)))
(progn
(lsp--apply-workspace-edit edits 'rename-file)
(funcall old-func old-name new-name ok-if-already-exists?)
(apply old-func old-name new-name args)
(when (lsp--send-did-rename-files-p)
(lsp-notify "workspace/didRenameFiles" params)))
(funcall old-func old-name new-name ok-if-already-exists?)))
(funcall old-func old-name new-name ok-if-already-exists?)))
(apply old-func old-name new-name args)))
(apply old-func old-name new-name args)))

(advice-add 'rename-file :around #'lsp--on-rename-file)
(advice-add 'vc-git-rename-file :around #'lsp--on-rename-file)

(defcustom lsp-xref-force-references nil
"If non-nil threat everything as references(e. g. jump if only one item.)"
Expand Down
Loading