Skip to content

Unable to use .chirp file with templates when .chirp file has CRLF line endings #112

Description

@jostly

Using cuicui_chirp 0.12.0 on Windows, with the following chirp file with CRLF line endings:

fn spacer() {
    Spacer(height(10px) width(10%) bg(coral))
}
Menu(screen_root row) {
    spacer!()
}

yields the following error:

2024-01-10T15:33:30.663376Z ERROR cuicui_chirp::loader::internal:   × Invalid chirp file: (0) Tried to call !, but this template doesn't exist.,

Error:   × Tried to call !, but this template doesn't exist.
   ╭─[ui/main_menu.chirp:2:1]
 2 │     Spacer(height(10px) width(10%) bg(coral))
 3 │ }
 4 │ Menu(screen_root row) {
   ·                        ─
 5 │     spacer!()
 6 │ }
   ╰────

Adding a trace logging line to cuicui_chirp parser/interpret.rs line 200-202

        let (mut name, span) = tpl.name().read_spanned(inp);
        trace!("{inp:?} {:?}", std::str::from_utf8(name));
        name = &name[..name.len() - 1];

shows the following trace logging:

2024-01-10T15:33:30.662934Z TRACE cuicui_chirp::parser::interpret: "fn spacer() {\r\n    Spacer(height(10px) width(10%) bg(coral))\r\n}\r\nMenu(screen_root row) {\r\n    spacer!()\r\n}" Ok("\r")

which led me to the following workaround:

Workaround

Switch the .chirp file to use LF line endings, at which point it loads as expected.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-chirprelates to the cuicui_chirp file format crate specificallyT-bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions