Skip to content

Language Server: Fix comments inside multiline ERB tags#1776

Open
RSeven wants to merge 2 commits into
marcoroth:mainfrom
RSeven:fix-1774-ruby-commenting
Open

Language Server: Fix comments inside multiline ERB tags#1776
RSeven wants to merge 2 commits into
marcoroth:mainfrom
RSeven:fix-1774-ruby-commenting

Conversation

@RSeven
Copy link
Copy Markdown

@RSeven RSeven commented Jun 5, 2026

Summary

This fixes comment handling for Ruby lines inside multiline ERB tags.

Issues resolved

Before, commenting the internal Ruby line with toggleLineComment produced HTML comments inside Ruby:

<%
  <!-- a -->
%>

After:

<%
  # a
%>

Before, block-commenting only the internal Ruby line with toggleBlockComment inserted nested ERB tags:

<%
  <% if false %>
  a
  <% end %>
%>

After:

<%
  # a
%>

Closes #1774

@RSeven RSeven force-pushed the fix-1774-ruby-commenting branch from 4337c30 to fb9db1a Compare June 5, 2026 22:38
@RSeven
Copy link
Copy Markdown
Author

RSeven commented Jun 5, 2026

Not sure about how to handle toggleBlockComment for multiline ERB tags. I thought about keeping the if block but it creates some strange behaviours, for example:

  1. Calling toggleBlockComment on the same selection twice doesn't really toggle the comment off, it just generates a new if block:
<%
  if false
    if false
      a
      b
    end
  end
%>
  1. Calling toggleBlockComment on a selection that includes the if clause and not the end will result in the following code that, even being valid, is probably not the expected behaviour:
<%
  if false
    if false
      a
  end
    b
  end
%>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commenting inside a ruby tag in an erb file is broken (comments as HTML)

1 participant