Skip to content

Commit 66ade34

Browse files
authored
Merge pull request #209 from sparkprime/fix_single_quote_fmt
Fix #197
2 parents a523d7f + bac3d43 commit 66ade34

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/formatter.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -990,16 +990,16 @@ class EnforceStringStyle : public Pass {
990990
if (c == '\'') num_single++;
991991
if (c == '"') num_double++;
992992
}
993-
if (num_single > 0 && num_double > 0) return;
994-
char style = opts.stringStyle == 's';
993+
if (num_single > 0 && num_double > 0) return; // Don't change it.
994+
bool use_single = opts.stringStyle == 's';
995995
if (num_single > 0)
996-
style = 'd';
996+
use_single = false;
997997
if (num_double > 0)
998-
style = 's';
998+
use_single = true;
999999

1000-
// Change it
1001-
lit->value = jsonnet_string_escape(canonical, style == 's');
1002-
lit->tokenKind = style ? LiteralString::SINGLE : LiteralString::DOUBLE;
1000+
// Change it.
1001+
lit->value = jsonnet_string_escape(canonical, use_single);
1002+
lit->tokenKind = use_single ? LiteralString::SINGLE : LiteralString::DOUBLE;
10031003
}
10041004
};
10051005

0 commit comments

Comments
 (0)