[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 0cbdbac: Strip trailing whitespaces at the end of c
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master 0cbdbac: Strip trailing whitespaces at the end of converted do block |
Date: |
Thu, 25 Jul 2019 09:02:05 -0400 (EDT) |
branch: master
commit 0cbdbac2bbc0ade799711cd70d3d59aee3db9cef
Author: Nobuyoshi Nakada <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Strip trailing whitespaces at the end of converted do block
* lisp/progmodes/ruby-mode.el (ruby-brace-to-do-end):
Strip trailing whitespaces at the end of converted do block
(bug#36756).
https://bugs.ruby-lang.org/issues/16014
https://github.com/syl20bnr/spacemacs/issues/12548
---
lisp/progmodes/ruby-mode.el | 3 ++-
test/lisp/progmodes/ruby-mode-tests.el | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 8eadf01..340c689 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1690,7 +1690,8 @@ See `add-log-current-defun-function'."
(when (eq (char-before) ?\})
(delete-char -1)
(when (save-excursion
- (skip-chars-backward " \t")
+ (let ((n (skip-chars-backward " \t")))
+ (if (< n 0) (delete-char (- n))))
(not (bolp)))
(insert "\n"))
(insert "end")
diff --git a/test/lisp/progmodes/ruby-mode-tests.el
b/test/lisp/progmodes/ruby-mode-tests.el
index efbe012..83fcdd8 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -369,7 +369,11 @@ VALUES-PLIST is a list with alternating index and value
elements."
(ruby-with-temp-buffer "foo {|b|\n}"
(beginning-of-line)
(ruby-toggle-block)
- (should (string= "foo do |b|\nend" (buffer-string)))))
+ (should (string= "foo do |b|\nend" (buffer-string))))
+ (ruby-with-temp-buffer "foo {|b| b }"
+ (beginning-of-line)
+ (ruby-toggle-block)
+ (should (string= "foo do |b|\n b\nend" (buffer-string)))))
(ert-deftest ruby-toggle-block-to-brace ()
(let ((pairs '((17 . "foo { |b| b + 2 }")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 0cbdbac: Strip trailing whitespaces at the end of converted do block,
Dmitry Gutov <=