Skip to content

Determine comment tokens from injection layers #7364

Open
@the-mikedavis

Description

@the-mikedavis

toggle_comments should take language injections into account. For example in HTML:

<p>
  C-c on this line should use the HTML comment token(s).
</p>
<script type="text/javascript">
  // C-c on this line should use the javascript comment token(s).
  foo();
</script>

To do this we should look at the byte range for each Range in the current Selection and find the LanguageLayer in doc.syntax() (Syntax) with the smallest/deepest range that completely covers the selection range. We will then need a way to find the LanguageConfiguration for a given LanguageLayer and then we can use that LanguageConfiguration's comment_token for that range in the selection.

The changes for this will conflict with #1505 / #4718 so this feature may be better off waiting for those changes to land.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coreArea: Helix core improvementsA-tree-sitterArea: Tree-sitterC-enhancementCategory: ImprovementsE-mediumCall for participation: Experience needed to fix: Medium / intermediate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions