Skip to content

Syntax highlights incorrect for round brackets macro vs curly braces #13234

@nixonyh

Description

@nixonyh

Summary

Image

Image

Reproduction Steps

I tried this:

  1. Changing the theme doesn't work. STill the same highlight behaviour.

I expected this to happen: Syntax highlight should be the same as both.
z
Instead, this happened: It's different

Here's the code for copy pasting:

correct version:

macro_rules! typst_func {
    (
        $( #[$attr:meta] )*
        $vis:vis struct $struct_name:ident {
            $( $pos_arg:ident: $pos_type:ty, )*
            $(
                #[named]
                $( $named_arg:ident: $named_type:ty, )*
            )?
        }
    ) => {
        $( #[$attr] )*
        $vis struct $struct_name {
            $($pos_arg: $pos_type,)*
            $($($named_arg: Option<$named_type>,)*)?
        }
    };
}

typst_func! {
    #[derive(Resource, Reflect, Default)]
    #[reflect(Resource)]
    pub struct MainFunc {
        pos_arg0: f64,
        pos_arg1: u32,
        // Anything below the this will be a named argument.
        #[named]
        named_arg0: bool,
        named_arg1: i32,
        named_arg2: String,
    }
}

fn test() {
    let main = MainFunc::default();
}

Not working correctly version:

macro_rules! typst_func {
    (
        $( #[$attr:meta] )*
        $vis:vis struct $struct_name:ident {
            $( $pos_arg:ident: $pos_type:ty, )*
            $(
                #[named]
                $( $named_arg:ident: $named_type:ty, )*
            )?
        }
    ) => {
        $( #[$attr] )*
        $vis struct $struct_name {
            $($pos_arg: $pos_type,)*
            $($($named_arg: Option<$named_type>,)*)?
        }
    };
}

typst_func! (
    #[derive(Resource, Reflect, Default)]
    #[reflect(Resource)]
    pub struct MainFunc {
        pos_arg0: f64,
        pos_arg1: u32,
        // Anything below the this will be a named argument.
        #[named]
        named_arg0: bool,
        named_arg1: i32,
        named_arg2: String,
    }
);

fn test() {
    let main = MainFunc::default();
}

Helix log

N/A

Platform

Windows

Terminal Emulator

Windows terminal

Installation Method

cargo

Helix Version

main (388a3b7)

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