@@ -4563,12 +4563,12 @@ interface TextDocumentEdit {
4563
4563
(lsp:set-position-line (max 0 line))
4564
4564
(lsp:set-position-character (max 0 character))))
4565
4565
4566
- (lsp-defun lsp--apply-text-edit-replace-buffer -contents ((edit &as
4566
+ (lsp-defun lsp--apply-text-edit-replace-region -contents ((edit &as
4567
4567
&TextEdit
4568
4568
:range (&Range :start :end)
4569
4569
:new-text))
4570
4570
"Apply the edits described in the TextEdit object in TEXT-EDIT.
4571
- The method uses `replace-buffer -contents'."
4571
+ The method uses `replace-region -contents'."
4572
4572
(setq new-text (s-replace "\r" "" (or new-text "")))
4573
4573
(lsp:set-text-edit-new-text edit new-text)
4574
4574
(-let* ((source (current-buffer))
@@ -4580,21 +4580,12 @@ The method uses `replace-buffer-contents'."
4580
4580
(with-current-buffer source
4581
4581
(save-excursion
4582
4582
(save-restriction
4583
- (narrow-to-region beg end)
4584
-
4585
- ;; On emacs versions < 26.2,
4586
- ;; `replace-buffer-contents' is buggy - it calls
4587
- ;; change functions with invalid arguments - so we
4588
- ;; manually call the change functions here.
4589
- ;;
4590
- ;; See emacs bugs #32237, #32278:
4591
- ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32237
4592
- ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32278
4593
4583
(let ((inhibit-modification-hooks t)
4594
4584
(length (- end beg)))
4595
4585
(run-hook-with-args 'before-change-functions
4596
4586
beg end)
4597
- (replace-buffer-contents temp)
4587
+ (replace-region-contents beg end
4588
+ (lambda (&rest _) temp))
4598
4589
(run-hook-with-args 'after-change-functions
4599
4590
beg (+ beg (length new-text))
4600
4591
length)))))))))
@@ -4670,7 +4661,7 @@ OPERATION is symbol representing the source of this text edit."
4670
4661
(reporter (make-progress-reporter message 0 howmany))
4671
4662
(done 0)
4672
4663
(apply-edit (if (not lsp--virtual-buffer)
4673
- #'lsp--apply-text-edit-replace-buffer -contents
4664
+ #'lsp--apply-text-edit-replace-region -contents
4674
4665
#'lsp--apply-text-edit)))
4675
4666
(unwind-protect
4676
4667
(->> edits
0 commit comments