diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 88ac66d82..e64110c26 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -2915,7 +2915,7 @@ fn cmd_debug( } DebugCommands::Template(template_matches) => { let parse = TemplateParser::parse( - crate::template_parser::Rule::template, + crate::template_parser::Rule::program, &template_matches.template, ); writeln!(ui, "{parse:#?}")?; diff --git a/src/template.pest b/src/template.pest index 841d91776..70b8d1ac8 100644 --- a/src/template.pest +++ b/src/template.pest @@ -48,3 +48,5 @@ list = _{ template = { whitespace* ~ (list | term | "") ~ whitespace* } + +program = _{ SOI ~ template ~ EOI } diff --git a/src/template_parser.rs b/src/template_parser.rs index e6650aab1..a396c66f7 100644 --- a/src/template_parser.rs +++ b/src/template_parser.rs @@ -381,17 +381,7 @@ pub fn parse_commit_template<'a>( workspace_id: &WorkspaceId, template_text: &str, ) -> Box + 'a> { - let mut pairs: Pairs = TemplateParser::parse(Rule::template, template_text).unwrap(); - + let mut pairs: Pairs = TemplateParser::parse(Rule::program, template_text).unwrap(); let first_pair = pairs.next().unwrap(); - assert!(pairs.next().is_none()); - - assert_eq!( - first_pair.as_span().end(), - template_text.len(), - "failed to parse template past position {}", - first_pair.as_span().end() - ); - parse_commit_template_rule(repo, workspace_id, first_pair) }