@@ -170,19 +170,7 @@ fn render_welcome_text(
170170 && let Some ( highlights) = guideline_highlights
171171 && !highlights. is_empty ( )
172172 {
173- let details: Vec < String > = highlights
174- . iter ( )
175- . take ( 2 )
176- . map ( |item| item. trim ( ) )
177- . filter ( |item| !item. is_empty ( ) )
178- . map ( |item| format ! ( "- {}" , item) )
179- . collect ( ) ;
180- add_section (
181- & mut sections,
182- style_section_title ( "Key Guidelines" ) ,
183- details,
184- SectionSpacing :: Flush ,
185- ) ;
173+ add_guideline_sections ( & mut sections, highlights) ;
186174 }
187175
188176 if onboarding_cfg. include_usage_tips_in_welcome {
@@ -366,6 +354,40 @@ fn add_list_section(
366354 add_section ( sections, style_section_title ( title) , body, spacing) ;
367355}
368356
357+ fn add_guideline_sections ( sections : & mut Vec < SectionBlock > , highlights : & [ String ] ) {
358+ let entries: Vec < String > = highlights
359+ . iter ( )
360+ . map ( |item| item. trim ( ) )
361+ . filter ( |item| !item. is_empty ( ) )
362+ . map ( |item| item. to_string ( ) )
363+ . collect ( ) ;
364+
365+ if entries. is_empty ( ) {
366+ return ;
367+ }
368+
369+ for entry in entries {
370+ if let Some ( ( title, detail) ) = entry. split_once ( ':' ) {
371+ let title = title. trim_matches ( '*' ) . trim ( ) ;
372+ let mut lines = vec ! [ style_section_title( title) ] ;
373+ let detail = detail. trim ( ) ;
374+ if !detail. is_empty ( ) {
375+ lines. push ( detail. to_string ( ) ) ;
376+ }
377+ sections. push ( SectionBlock :: new ( lines, SectionSpacing :: Normal ) ) ;
378+ } else {
379+ let title = entry. trim_matches ( '*' ) . trim ( ) ;
380+ if title. is_empty ( ) {
381+ continue ;
382+ }
383+ sections. push ( SectionBlock :: new (
384+ vec ! [ style_section_title( title) ] ,
385+ SectionSpacing :: Normal ,
386+ ) ) ;
387+ }
388+ }
389+ }
390+
369391fn add_keyboard_shortcut_section ( sections : & mut Vec < SectionBlock > ) {
370392 let hint = ui_constants:: HEADER_SHORTCUT_HINT . trim ( ) ;
371393 if hint. is_empty ( ) {
@@ -385,7 +407,18 @@ fn add_keyboard_shortcut_section(sections: &mut Vec<SectionBlock>) {
385407 . split ( ui_constants:: WELCOME_SHORTCUT_SEPARATOR )
386408 . map ( str:: trim)
387409 . filter ( |part| !part. is_empty ( ) )
388- . map ( |part| format ! ( "{}{}" , ui_constants:: WELCOME_SHORTCUT_INDENT , part) )
410+ . filter_map ( |part| {
411+ let formatted = format_shortcut_entry ( part) ;
412+ if formatted. is_empty ( ) {
413+ None
414+ } else {
415+ Some ( format ! (
416+ "{}{}" ,
417+ ui_constants:: WELCOME_SHORTCUT_INDENT ,
418+ formatted
419+ ) )
420+ }
421+ } )
389422 . collect ( ) ;
390423
391424 if entries. is_empty ( ) {
@@ -416,7 +449,7 @@ fn add_slash_command_section(sections: &mut Vec<SectionBlock>) {
416449 info. name
417450 ) ;
418451 format ! (
419- "{}{} {}" ,
452+ "{} `{}` {}" ,
420453 ui_constants:: WELCOME_SLASH_COMMAND_INDENT ,
421454 command,
422455 info. description
@@ -447,6 +480,33 @@ fn add_slash_command_section(sections: &mut Vec<SectionBlock>) {
447480 ) ;
448481}
449482
483+ fn format_shortcut_entry ( entry : & str ) -> String {
484+ if let Some ( ( keys, action) ) = entry. split_once ( " to " ) {
485+ let keys = keys. trim ( ) ;
486+ let action = action. trim ( ) ;
487+ if action. is_empty ( ) {
488+ format ! ( "`{}`" , keys)
489+ } else {
490+ format ! ( "`{}` to {}" , keys, action)
491+ }
492+ } else if let Some ( ( keys, rest) ) = entry. split_once ( ' ' ) {
493+ let keys = keys. trim ( ) ;
494+ let rest = rest. trim ( ) ;
495+ if rest. is_empty ( ) {
496+ format ! ( "`{}`" , keys)
497+ } else {
498+ format ! ( "`{}` {}" , keys, rest)
499+ }
500+ } else {
501+ let trimmed = entry. trim ( ) ;
502+ if trimmed. is_empty ( ) {
503+ String :: new ( )
504+ } else {
505+ format ! ( "`{}`" , trimmed)
506+ }
507+ }
508+ }
509+
450510#[ derive( Clone , Copy , PartialEq , Eq ) ]
451511enum SectionSpacing {
452512 Normal ,
@@ -605,7 +665,6 @@ mod tests {
605665 let styled_title = theme:: active_styles ( ) . primary . bold ( ) ;
606666 let prefix = Styles :: render ( & styled_title) ;
607667 let reset = Styles :: render_reset ( ) ;
608- let styled_guidelines = format ! ( "{prefix}Key Guidelines{reset}" ) ;
609668 let styled_shortcuts = format ! (
610669 "{prefix}{}{reset}" ,
611670 ui_constants:: WELCOME_SHORTCUT_SECTION_TITLE
@@ -616,28 +675,29 @@ mod tests {
616675 assert ! ( welcome. contains( "**Project:" ) ) ;
617676 assert ! ( welcome. contains( "Tip one" ) ) ;
618677 assert ! ( welcome. contains( "Follow workspace guidelines" ) ) ;
619- assert ! ( welcome. contains( & styled_guidelines) ) ;
678+ let styled_follow = style_section_title ( "Follow workspace guidelines" ) ;
679+ assert ! ( welcome. contains( & styled_follow) ) ;
620680 assert ! ( welcome. contains( & styled_shortcuts) ) ;
621681 assert ! ( plain. contains( "Keyboard Shortcuts" ) ) ;
622- assert ! ( plain. contains( "Key Guidelines" ) ) ;
682+ assert ! ( !plain. contains( "Key Guidelines" ) ) ;
683+ assert ! ( plain. contains( "Project Overview" ) ) ;
623684 let styled_slash_commands =
624685 style_section_title ( ui_constants:: WELCOME_SLASH_COMMAND_SECTION_TITLE ) ;
625686 assert ! ( welcome. contains( & styled_slash_commands) ) ;
626687 assert ! ( welcome. contains( ui_constants:: WELCOME_SLASH_COMMAND_INTRO ) ) ;
627- assert ! ( welcome . contains ( & format!(
628- "{}{}init" ,
688+ let init_command = format ! (
689+ "{} ` {}init` " ,
629690 ui_constants:: WELCOME_SLASH_COMMAND_INDENT ,
630691 ui_constants:: WELCOME_SLASH_COMMAND_PREFIX
631- ) ) ) ;
632- assert ! ( !welcome. contains( & format!(
633- "{}{}help" ,
692+ ) ;
693+ assert ! ( welcome. contains( & init_command) ) ;
694+ let help_command = format ! (
695+ "{} `{}help`" ,
634696 ui_constants:: WELCOME_SLASH_COMMAND_INDENT ,
635697 ui_constants:: WELCOME_SLASH_COMMAND_PREFIX
636- ) ) ) ;
637- assert ! ( welcome. contains( & format!(
638- "{}Ctrl+Enter" ,
639- ui_constants:: WELCOME_SHORTCUT_INDENT
640- ) ) ) ;
698+ ) ;
699+ assert ! ( !welcome. contains( & help_command) ) ;
700+ assert ! ( welcome. contains( "`Ctrl+Enter`" ) ) ;
641701 assert ! ( !plain. contains( "\n \n Key Guidelines" ) ) ;
642702 assert ! ( !plain. contains( "\n \n Keyboard Shortcuts" ) ) ;
643703
@@ -708,17 +768,19 @@ mod tests {
708768 assert ! ( !plain. contains( "\n \n Keyboard Shortcuts" ) ) ;
709769 assert ! ( welcome. contains( "Slash Commands" ) ) ;
710770 assert ! ( welcome. contains( ui_constants:: WELCOME_SLASH_COMMAND_INTRO ) ) ;
711- assert ! ( welcome . contains ( & format!(
712- "{}{}command" ,
771+ let command_entry = format ! (
772+ "{} ` {}command` " ,
713773 ui_constants:: WELCOME_SLASH_COMMAND_INDENT ,
714774 ui_constants:: WELCOME_SLASH_COMMAND_PREFIX
715- ) ) ) ;
716- assert ! ( !welcome. contains( & format!(
717- "{}{}help" ,
775+ ) ;
776+ assert ! ( welcome. contains( & command_entry) ) ;
777+ let help_entry = format ! (
778+ "{} `{}help`" ,
718779 ui_constants:: WELCOME_SLASH_COMMAND_INDENT ,
719780 ui_constants:: WELCOME_SLASH_COMMAND_PREFIX
720- ) ) ) ;
721- assert ! ( welcome. contains( & format!( "{}Esc" , ui_constants:: WELCOME_SHORTCUT_INDENT ) ) ) ;
781+ ) ;
782+ assert ! ( !welcome. contains( & help_entry) ) ;
783+ assert ! ( welcome. contains( "`Esc`" ) ) ;
722784
723785 if let Some ( value) = previous {
724786 unsafe {
0 commit comments