1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Fix quote escaping in ruby-toggle-string-quotes

* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
Change logic to quote based on the current quote of the string.

* test/lisp/progmodes/ruby-mode-tests.el
(ruby-toggle-string-quotes-quotes-correctly): Add test.

Copyright-paperwork-exempt: yes
This commit is contained in:
Sriram Thaiyar 2016-06-22 09:21:26 -07:00 committed by Dmitry Gutov
parent dd98ee8992
commit 7f02dedfca
2 changed files with 12 additions and 1 deletions

View file

@ -716,6 +716,17 @@ VALUES-PLIST is a list with alternating index and value elements."
(ruby-backward-sexp)
(should (= 2 (line-number-at-pos)))))
(ert-deftest ruby-toggle-string-quotes-quotes-correctly ()
(let ((pairs
'(("puts 'foo\"\\''" . "puts \"foo\\\"'\"")
("puts \"foo'\\\"\"" . "puts 'foo\\'\"'"))))
(dolist (pair pairs)
(ruby-with-temp-buffer (car pair)
(beginning-of-line)
(search-forward "foo")
(ruby-toggle-string-quotes)
(should (string= (buffer-string) (cdr pair)))))))
(ert-deftest ruby--insert-coding-comment-ruby-style ()
(with-temp-buffer
(let ((ruby-encoding-magic-comment-style 'ruby))