Also handle escaping when string begins with a quote
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes): Handle quoting of the first character in the string. * test/lisp/progmodes/ruby-mode-tests.el (ruby-toggle-string-quotes-quotes-correctly): Update.
This commit is contained in:
parent
7f02dedfca
commit
15c307417f
2 changed files with 4 additions and 4 deletions
|
@ -1800,8 +1800,8 @@ If the result is do-end block, it will always be multiline."
|
|||
(buffer-substring-no-properties (1+ min) (1- max))))
|
||||
(setq content
|
||||
(if (equal string-quote "'")
|
||||
(replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\([^\\\\]\\)'" "\\1\\\\'" content))
|
||||
(replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\([^\\\\]\\)\"" "\\1\\\\\"" content))))
|
||||
(replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\(\\`\\|[^\\\\]\\)'" "\\1\\\\'" content))
|
||||
(replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\(\\`\\|[^\\\\]\\)\"" "\\1\\\\\"" content))))
|
||||
(let ((orig-point (point)))
|
||||
(delete-region min max)
|
||||
(insert
|
||||
|
|
|
@ -718,8 +718,8 @@ VALUES-PLIST is a list with alternating index and value elements."
|
|||
|
||||
(ert-deftest ruby-toggle-string-quotes-quotes-correctly ()
|
||||
(let ((pairs
|
||||
'(("puts 'foo\"\\''" . "puts \"foo\\\"'\"")
|
||||
("puts \"foo'\\\"\"" . "puts 'foo\\'\"'"))))
|
||||
'(("puts '\"foo\"\\''" . "puts \"\\\"foo\\\"'\"")
|
||||
("puts \"'foo'\\\"\"" . "puts '\\'foo\\'\"'"))))
|
||||
(dolist (pair pairs)
|
||||
(ruby-with-temp-buffer (car pair)
|
||||
(beginning-of-line)
|
||||
|
|
Loading…
Add table
Reference in a new issue