Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7de3f6

Browse files
committed
Fix formatting for CHAR node when single_quotes plugin is enabled
1 parent909b45a commitc7de3f6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

‎lib/syntax_tree/node.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def format(q)
288288
q.text(value)
289289
else
290290
q.text(q.quote)
291-
q.text(value[1] =="\"" ?"\\\"" :value[1])
291+
q.text(value[1] ==q.quote ?"\\#{q.quote}" :value[1])
292292
q.text(q.quote)
293293
end
294294
end

‎test/plugin/single_quotes_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ def test_empty_string_literal
88
assert_format("''\n","\"\"")
99
end
1010

11+
deftest_character_literal_with_double_quote
12+
assert_format("'\"'\n","?\"")
13+
end
14+
15+
deftest_character_literal_with_singlee_quote
16+
assert_format("'\\''\n","?'")
17+
end
18+
1119
deftest_string_literal
1220
assert_format("'string'\n","\"string\"")
1321
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp