Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
novaugust committed Nov 27, 2023
1 parent 8c55f79 commit 580ce03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## main

### Improvements

* charlists: leave charlist rewriting to elixir's formatter on elixir >= 1.15

### Fixes

* charlists: rewrite empty charlist to use sigil (`''` => `~c""`)

## v0.10.2

### Improvements
Expand Down
5 changes: 1 addition & 4 deletions lib/style/single_node.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ defmodule Styler.Style.SingleNode do

def run({node, meta}, ctx), do: {:cont, {style(node), meta}, ctx}

# old `'charlist'` literals to `~c"charlist"`
# as of 1.15, elixir's formatter takes care of this for us.
if Version.match?(System.version(), "< 1.15.0-dev") do
# Our use of the `literal_encoder` option of `Code.string_to_quoted_with_comments!/2` creates
# invalid charlists literal AST nodes from `'foo'`. this rewrites them to use the `~c` sigil
# 'foo' => ~c"foo".
# 'charlist' => ~c"charlist"
defp style({:__block__, meta, [chars]} = node) when is_list(chars) do
if meta[:delimiter] == "'" do
{:sigil_c, Keyword.put(meta, :delimiter, "\""), [{:<<>>, [line: meta[:line]], [List.to_string(chars)]}, []]}
Expand Down

0 comments on commit 580ce03

Please sign in to comment.