Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jostly opened this issue Jan 10, 2024 · 3 comments
Labels
C-chirp relates to the cuicui_chirp file format crate specifically T-bug Something isn't working

Comments

@jostly
Copy link

jostly commented Jan 10, 2024

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.

@nicopap nicopap added T-bug Something isn't working C-chirp relates to the cuicui_chirp file format crate specifically labels Jan 11, 2024
@nicopap
Copy link
Owner

nicopap commented Jan 11, 2024

Thanks for the super detailed bug report!

With your help, I think I could figure out where the issue is:

const END_SPACE: [u8; END_SPACE_COUNT] = *b"/ \n\t";

Need to add a \r in there eh.

@jostly
Copy link
Author

jostly commented Jan 11, 2024

Yeah, I think that would do it :)

@nicopap
Copy link
Owner

nicopap commented Jan 27, 2024

I will push an update Monday with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-chirp relates to the cuicui_chirp file format crate specifically T-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants