Skip to content
Open
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
2 changes: 1 addition & 1 deletion CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
* Add support for the ~javascript.preferences.importModuleSpecifierEnding~ and ~typescript.preferences.importModuleSpecifierEnding~ preferences.
* Fix missing ty (a fast python language server) inlay hints when ~lsp-use-plist~ is true
* Add wasm-language-tools support
* Add ~lsp-ruff-multi-root~ variable to allow disabling multi-root option for ruff client
* feat: dedup text edits

** 9.0.0
* Add language server config for QML (Qt Modeling Language) using qmlls.
Expand Down
9 changes: 9 additions & 0 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -4589,6 +4589,14 @@ interface TextDocumentEdit {
(and (= left-line right-line)
(= left-character right-character)))

(lsp-defun lsp--text-edit-equal ((&TextEdit :range (&Range :start left-start :end left-end) :new-text left-new-text)
(&TextEdit :range (&Range :start right-start :end right-end) :new-text right-new-text))
"Return whether LEFT and RIGHT text edits are equal."
(and (equal left-new-text right-new-text)
(lsp--position-equal left-start right-start)
(lsp--position-equal left-end right-end)
(not (lsp--position-equal left-start left-end))))

(lsp-defun lsp--text-edit-sort-predicate ((&TextEdit :range (&Range :start left-start :end left-end))
(&TextEdit :range (&Range :start right-start :end right-end)))
(if (lsp--position-equal left-start right-start)
Expand Down Expand Up @@ -4698,6 +4706,7 @@ LSP server result."
(defun lsp--apply-text-edits (edits &optional operation)
"Apply the EDITS described in the TextEdit[] object.
OPERATION is symbol representing the source of this text edit."
(setq edits (seq-uniq edits #'lsp--text-edit-equal))
(unless (seq-empty-p edits)
(atomic-change-group
(run-hooks 'lsp-before-apply-edits-hook)
Expand Down
Loading