Skip to content

Typst treesitter mm inconsistency #15287

@axelcool1234

Description

@axelcool1234

Summary

Suppose you had the following code:

#set heading(numbering: none)

When your cursor is on (, typing mm does nothing. I manually added a panic that outputs the pretty printed tree of the node in find_pair. This is outputted:

```tsq
(call
  item: (ident)
  (group "("
    (tagged
      field: (ident) ":"
      (none)) ")"))

Now let's say you had the following erroneous code:

#set heading (numbering: none)

When your cursor is on (, typing mm correctly moves you to ).

With the added panic, this is outputted:

```tsq
"("

I am not very familiar with treesitter grammars. It seems as if the lack of space between the parenthesis and the ident in the call node prevents helix from getting the "smallest node" when calling descendant_for_byte_range. Or it seems as if the call node is the smallest node somehow.

I looked around in Typst's grammar, this is call:
https://github.com/uben0/tree-sitter-typst/blob/46cf4ded12ee974a70bf8457263b67ad7ee0379d/grammar.js#L420C1-L420C142

Could it be that the $._immediate_paren here consumes the open paren, which is why Helix fails to see "("?

Reproduction Steps

No response

Helix log

No response

Platform

Linux

Terminal Emulator

Kitty

Installation Method

nixpkgs

Helix Version

25.07.1 (a05c151)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions