fix: Always move back to same column after applying rcs patch

Previously the cursor would move to the beginning of line if the current
line was changed by `rubocopfmt`.

This fix is borrowed from:
https://github.com/dominikh/go-mode.el/pull/236
This commit is contained in:
2020-05-26 23:37:37 +01:00
parent bbfc30250b
commit 9b7c86a5ec

View File

@@ -113,7 +113,8 @@ to format buffer before saving, instead of `rubocopfmt'."
;; Appending lines decrements the offset (possibly making it
;; negative), deleting lines increments it. This order
;; simplifies the forward-line invocations.
(line-offset 0))
(line-offset 0)
(column (current-column)))
(save-excursion
(with-current-buffer patch-buffer
(goto-char (point-min))
@@ -140,7 +141,8 @@ to format buffer before saving, instead of `rubocopfmt'."
(cl-incf line-offset len)
(rubocopfmt--delete-whole-line len)))
(t
(error "Invalid rcs patch or internal error in rubocopfmt--apply-rcs-patch")))))))))
(error "Invalid rcs patch or internal error in rubocopfmt--apply-rcs-patch")))))))
(move-to-column column)))
(defun rubocopfmt--delete-whole-line (&optional arg)
"Delete the current line without putting it in the `kill-ring'.