@@ -40,6 +40,9 @@ const enum PositronConsoleCommandId {
4040 ClearInputHistory = 'workbench.action.positronConsole.clearInputHistory' ,
4141 ExecuteCode = 'workbench.action.positronConsole.executeCode' ,
4242 FocusConsole = 'workbench.action.positronConsole.focusConsole' ,
43+ NavigateInputHistoryDown = 'workbench.action.positronConsole.navigateInputHistoryDown' ,
44+ NavigateInputHistoryUp = 'workbench.action.positronConsole.navigateInputHistoryUp' ,
45+ NavigateInputHistoryUpUsingPrefixMatch = 'workbench.action.positronConsole.navigateInputHistoryUpUsingPrefixMatch' ,
4346}
4447
4548/**
@@ -113,46 +116,6 @@ export function registerPositronConsoleActions() {
113116 }
114117 } ) ;
115118
116- /**
117- * Register the focus console action. This action places focus in the active console,
118- * if one exists.
119- *
120- * This action is equivalent to the `workbench.panel.positronConsole.focus` command.
121- */
122- registerAction2 ( class extends Action2 {
123- /**
124- * Constructor.
125- */
126- constructor ( ) {
127- super ( {
128- id : PositronConsoleCommandId . FocusConsole ,
129- title : {
130- value : localize ( 'workbench.action.positronConsole.focusConsole' , "Focus Console" ) ,
131- original : 'Focus Console'
132- } ,
133- f1 : true ,
134- keybinding : {
135- weight : KeybindingWeight . WorkbenchContrib ,
136- primary : KeyChord ( KeyMod . CtrlCmd | KeyCode . KeyK , KeyCode . KeyF )
137- } ,
138- category,
139- } ) ;
140- }
141-
142- /**
143- * Runs action; places focus in the console's input control.
144- *
145- * @param accessor The services accessor.
146- */
147- async run ( accessor : ServicesAccessor ) {
148- const viewsService = accessor . get ( IViewsService ) ;
149-
150- // Ensure that the panel and console are visible. This is essentially
151- // equivalent to what `workbench.panel.positronConsole.focus` does.
152- await viewsService . openView ( POSITRON_CONSOLE_VIEW_ID , true ) ;
153- }
154- } ) ;
155-
156119 /**
157120 * Register the clear input history action. This action removes everything from the active
158121 * console language's input history.
@@ -602,4 +565,158 @@ export function registerPositronConsoleActions() {
602565 model . pushEditOperations ( [ ] , [ editOperation ] , ( ) => [ ] ) ;
603566 }
604567 } ) ;
568+
569+ /**
570+ * Register the focus console action. This action places focus in the active console,
571+ * if one exists.
572+ *
573+ * This action is equivalent to the `workbench.panel.positronConsole.focus` command.
574+ */
575+ registerAction2 ( class extends Action2 {
576+ /**
577+ * Constructor.
578+ */
579+ constructor ( ) {
580+ super ( {
581+ id : PositronConsoleCommandId . FocusConsole ,
582+ title : {
583+ value : localize ( 'workbench.action.positronConsole.focusConsole' , "Focus Console" ) ,
584+ original : 'Focus Console'
585+ } ,
586+ f1 : true ,
587+ keybinding : {
588+ weight : KeybindingWeight . WorkbenchContrib ,
589+ primary : KeyChord ( KeyMod . CtrlCmd | KeyCode . KeyK , KeyCode . KeyF )
590+ } ,
591+ category,
592+ } ) ;
593+ }
594+
595+ /**
596+ * Runs action; places focus in the console's input control.
597+ *
598+ * @param accessor The services accessor.
599+ */
600+ async run ( accessor : ServicesAccessor ) {
601+ const viewsService = accessor . get ( IViewsService ) ;
602+
603+ // Ensure that the panel and console are visible. This is essentially
604+ // equivalent to what `workbench.panel.positronConsole.focus` does.
605+ await viewsService . openView ( POSITRON_CONSOLE_VIEW_ID , true ) ;
606+ }
607+ } ) ;
608+
609+ /**
610+ * Register the navigate input history down action. This action moves the cursor to the next
611+ * entry in the input history.
612+ */
613+ registerAction2 ( class extends Action2 {
614+ /**
615+ * Constructor.
616+ */
617+ constructor ( ) {
618+ super ( {
619+ id : PositronConsoleCommandId . NavigateInputHistoryDown ,
620+ title : {
621+ value : localize ( 'workbench.action.positronConsole.navigateInputHistoryDown' , "Navigate Input History Down" ) ,
622+ original : 'Navigate Input History Down'
623+ } ,
624+ f1 : true ,
625+ category,
626+ } ) ;
627+ }
628+
629+ /**
630+ * Runs action.
631+ * @param accessor The services accessor.
632+ */
633+ async run ( accessor : ServicesAccessor ) {
634+ const positronConsoleService = accessor . get ( IPositronConsoleService ) ;
635+ if ( positronConsoleService . activePositronConsoleInstance ) {
636+ positronConsoleService . activePositronConsoleInstance . navigateInputHistoryDown ( ) ;
637+ } else {
638+ accessor . get ( INotificationService ) . notify ( {
639+ severity : Severity . Info ,
640+ message : localize ( 'positron.navigateInputHistory.noActiveConsole' , "Cannot navigate input history. A console is not active." ) ,
641+ sticky : false
642+ } ) ;
643+ }
644+ }
645+ } ) ;
646+
647+ /**
648+ * Register the navigate input history up action. This action moves the cursor to the previous
649+ * entry in the input history.
650+ */
651+ registerAction2 ( class extends Action2 {
652+ /**
653+ * Constructor.
654+ */
655+ constructor ( ) {
656+ super ( {
657+ id : PositronConsoleCommandId . NavigateInputHistoryUp ,
658+ title : {
659+ value : localize ( 'workbench.action.positronConsole.navigateInputHistoryUp' , "Navigate Input History Up" ) ,
660+ original : 'Navigate Input History Up'
661+ } ,
662+ f1 : true ,
663+ category,
664+ } ) ;
665+ }
666+
667+ /**
668+ * Runs action.
669+ * @param accessor The services accessor.
670+ */
671+ async run ( accessor : ServicesAccessor ) {
672+ const positronConsoleService = accessor . get ( IPositronConsoleService ) ;
673+ if ( positronConsoleService . activePositronConsoleInstance ) {
674+ positronConsoleService . activePositronConsoleInstance . navigateInputHistoryUp ( false ) ;
675+ } else {
676+ accessor . get ( INotificationService ) . notify ( {
677+ severity : Severity . Info ,
678+ message : localize ( 'positron.navigateInputHistory.noActiveConsole' , "Cannot navigate input history. A console is not active." ) ,
679+ sticky : false
680+ } ) ;
681+ }
682+ }
683+ } ) ;
684+
685+ /**
686+ * Register the navigate history up prefix match action. This action moves the cursor to the previous
687+ * entry in the input history using the prefix match strategy.
688+ */
689+ registerAction2 ( class extends Action2 {
690+ /**
691+ * Constructor.
692+ */
693+ constructor ( ) {
694+ super ( {
695+ id : PositronConsoleCommandId . NavigateInputHistoryUpUsingPrefixMatch ,
696+ title : {
697+ value : localize ( 'workbench.action.positronConsole.navigateInputHistoryUpUsingPrefixMatch' , "Navigate Input History Up (Prefix Match)" ) ,
698+ original : 'Navigate Input History Up (Prefix Match)'
699+ } ,
700+ f1 : true ,
701+ category,
702+ } ) ;
703+ }
704+
705+ /**
706+ * Runs action.
707+ * @param accessor The services accessor.
708+ */
709+ async run ( accessor : ServicesAccessor ) {
710+ const positronConsoleService = accessor . get ( IPositronConsoleService ) ;
711+ if ( positronConsoleService . activePositronConsoleInstance ) {
712+ positronConsoleService . activePositronConsoleInstance . navigateInputHistoryUp ( true ) ;
713+ } else {
714+ accessor . get ( INotificationService ) . notify ( {
715+ severity : Severity . Info ,
716+ message : localize ( 'positron.navigateInputHistory.noActiveConsole' , "Cannot navigate input history. A console is not active." ) ,
717+ sticky : false
718+ } ) ;
719+ }
720+ }
721+ } ) ;
605722}
0 commit comments