Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in Elixir HEEx sigils are not highlighted #784

Open
crbelaus opened this issue Nov 16, 2024 · 1 comment · May be fixed by #785
Open

Changes in Elixir HEEx sigils are not highlighted #784

crbelaus opened this issue Nov 16, 2024 · 1 comment · May be fixed by #785

Comments

@crbelaus
Copy link

When changing code inside an embedded HEEx sigil on Elixir, difftastic is not highlighting the changes but the whole sigil.

I have the following code:

  def render(assigns) do
    if assigns.count == 5 do
      raise "Crash on render"
    end

    ~H"""
    <span><%= @count %></span>
    <button phx-click="inc">+</button>
    <button phx-click="dec">-</button>
    <button phx-click="error">Crash on handle_event</button>

    <.link href="/?crash=mount">Crash on mount</.link>
    <.link patch="/?crash=handle_params">Crash on handle_params</.link>

    <style type="text/css">
      body { padding: 1em; }
    </style>
    """
  end

And I change it to (just added the new class to the first <span> element):

  def render(assigns) do
    if assigns.count == 5 do
      raise "Crash on render"
    end

    ~H"""
    <span class="new"><%= @count %></span>
    <button phx-click="inc">+</button>
    <button phx-click="dec">-</button>
    <button phx-click="error">Crash on handle_event</button>

    <.link href="/?crash=mount">Crash on mount</.link>
    <.link patch="/?crash=handle_params">Crash on handle_params</.link>

    <style type="text/css">
      body { padding: 1em; }
    </style>
    """
  end

When using basic git diff it highlights the changed line. On the other hand, difftastic highlights the whole block:

image

It is important to note that diffs are properly highlighted on HEEx files. The problem appears only on embedded HEEx blocks.

I am using latest difftastic on MacOS:

Difftastic 0.61.0

Toolchain: 1.82.0
System:    macos aarch64
@crbelaus crbelaus changed the title Elixir HEEx diff doesn't highlight the changes Changes in Elixir HEEx sigils are not highlighted Nov 16, 2024
@crbelaus
Copy link
Author

I believe that the involved tree sitter parsers are:

@crbelaus crbelaus linked a pull request Nov 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant