From 9b7c86a5ec533381fd4f41aba01bdcf6277dc2a6 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 26 May 2020 23:37:37 +0100 Subject: [PATCH] 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 --- rubocopfmt.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rubocopfmt.el b/rubocopfmt.el index efa652f..50ce94b 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -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'.