@@ -554,22 +554,18 @@ public static String fish(String scriptName, CommandLine commandLine) {
554554 continue ;
555555 }
556556 if (!descriptor .parentFunctionName .equals (parentFunction )) {
557- if (!currentLevelCommands .isEmpty ()) {
558- processLevel (scriptName , result , currentLevel , currentLevelCommands , parentFunction , rootDescriptor );
559- rootDescriptor = null ;
557+ processLevel (scriptName , result , currentLevel , currentLevelCommands , parentFunction , rootDescriptor );
558+ rootDescriptor = null ;
560559
561- currentLevel .clear ();
562- currentLevelCommands .clear ();
563- }
560+ currentLevel .clear ();
561+ currentLevelCommands .clear ();
564562 parentFunction = descriptor .parentFunctionName ;
565563 }
566564
567565 currentLevel .add (descriptor );
568566 currentLevelCommands .add (descriptor .commandName );
569567 }
570- if (!currentLevelCommands .isEmpty ()) {
571- processLevel (scriptName , result , currentLevel , currentLevelCommands , parentFunction , rootDescriptor );
572- }
568+ processLevel (scriptName , result , currentLevel , currentLevelCommands , parentFunction , rootDescriptor );
573569
574570
575571 return result .toString ();
@@ -578,7 +574,10 @@ public static String fish(String scriptName, CommandLine commandLine) {
578574 private static void processLevel (String scriptName , StringBuilder result , List <CommandDescriptor > currentLevel ,
579575 List <String > currentLevelCommands , String levelName ,
580576 CommandDescriptor rootDescriptor ) {
581- result .append ("\n # " ).append (levelName ).append (" completion \n " );
577+ if (levelName .equals ("" )) {
578+ levelName = "root" ;
579+ }
580+ result .append ("\n # " ).append (levelName ).append (" completion\n " );
582581 result .append ("set -l " ).append (levelName ).append (" " ).append (String .join (" " , currentLevelCommands )).append (
583582 "\n " );
584583 if (rootDescriptor != null ) {
0 commit comments