@@ -48,25 +48,30 @@ export function activate(context: vscode.ExtensionContext): void {
48
48
eventEmitter . emit ( 'run-minecraft-command' , 'reload' ) ;
49
49
} ) ;
50
50
51
- // Create a command to allow keyboard shortcuts to run Minecraft commands
52
- const runMinecraftCommand = vscode . commands . registerCommand (
53
- 'minecraft-debugger.runMinecraftCommand' ,
54
- ( ...args : unknown [ ] ) => {
55
- if ( args . length === 0 ) {
51
+ const runMinecraftCommand = vscode . commands . registerCommand ( 'minecraft-debugger.runMinecraftCommand' , ( ) => {
52
+ if ( ! vscode . debug . activeDebugSession ) {
53
+ vscode . window . showErrorMessage ( 'Error running command: No active Minecraft Debugger session.' ) ;
54
+ return ;
55
+ }
56
+
57
+ vscode . window . showInputBox ( {
58
+ placeHolder : 'Please enter the command to run.' ,
59
+ value : '' ,
60
+ } ) . then ( command => {
61
+ if ( ! command ) {
56
62
vscode . window . showErrorMessage ( 'No command provided.' ) ;
57
63
return ;
58
64
}
59
- const command = args [ 0 ] ; // Use only the first argument
60
- if ( typeof command !== 'string' ) {
61
- vscode . window . showErrorMessage ( 'Command must be a string.' ) ;
62
- return ;
63
- }
65
+
66
+ // Check for active session again in case the session closed while the prompt was open
64
67
if ( ! vscode . debug . activeDebugSession ) {
65
68
vscode . window . showErrorMessage ( 'Error running command: No active Minecraft Debugger session.' ) ;
69
+ return ;
66
70
}
71
+
67
72
eventEmitter . emit ( 'run-minecraft-command' , command ) ;
68
- }
69
- ) ;
73
+ } ) ;
74
+ } ) ;
70
75
71
76
const liveDiagnosticsCommand = vscode . commands . registerCommand ( 'minecraft-debugger.liveDiagnostics' , ( ) => {
72
77
MinecraftDiagnosticsPanel . render ( context . extensionUri , liveStatsProvider ) ;
0 commit comments