Skip to content

Commit

Permalink
Merge pull request #209 from sparkprime/fix_single_quote_fmt
Browse files Browse the repository at this point in the history
Fix #197
  • Loading branch information
sparkprime authored Jun 23, 2016
2 parents a523d7f + bac3d43 commit 66ade34
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,16 +990,16 @@ class EnforceStringStyle : public Pass {
if (c == '\'') num_single++;
if (c == '"') num_double++;
}
if (num_single > 0 && num_double > 0) return;
char style = opts.stringStyle == 's';
if (num_single > 0 && num_double > 0) return; // Don't change it.
bool use_single = opts.stringStyle == 's';
if (num_single > 0)
style = 'd';
use_single = false;
if (num_double > 0)
style = 's';
use_single = true;

// Change it
lit->value = jsonnet_string_escape(canonical, style == 's');
lit->tokenKind = style ? LiteralString::SINGLE : LiteralString::DOUBLE;
// Change it.
lit->value = jsonnet_string_escape(canonical, use_single);
lit->tokenKind = use_single ? LiteralString::SINGLE : LiteralString::DOUBLE;
}
};

Expand Down

0 comments on commit 66ade34

Please sign in to comment.