@@ -121,15 +121,43 @@ export async function getCwdForSplit(
121
121
}
122
122
123
123
export const terminalSendSequenceCommand = async ( accessor : ServicesAccessor , args : unknown ) => {
124
- const instance = accessor . get ( ITerminalService ) . activeInstance ;
124
+ const quickInputService = accessor . get ( IQuickInputService ) ;
125
+ const configurationResolverService = accessor . get ( IConfigurationResolverService ) ;
126
+ const workspaceContextService = accessor . get ( IWorkspaceContextService ) ;
127
+ const historyService = accessor . get ( IHistoryService ) ;
128
+ const terminalService = accessor . get ( ITerminalService ) ;
129
+
130
+ const instance = terminalService . activeInstance ;
125
131
if ( instance ) {
126
- const text = isObject ( args ) && 'text' in args ? toOptionalString ( args . text ) : undefined ;
132
+ let text = isObject ( args ) && 'text' in args ? toOptionalString ( args . text ) : undefined ;
133
+
134
+ // If no text provided, prompt user for input and process special characters
127
135
if ( ! text ) {
128
- return ;
136
+ text = await quickInputService . input ( {
137
+ value : '' ,
138
+ placeHolder : 'Enter sequence to send (supports \\n, \\r, \\x{AB})' ,
139
+ prompt : localize ( 'workbench.action.terminal.sendSequence.prompt' , "Enter sequence to send to the terminal" ) ,
140
+ } ) ;
141
+ if ( ! text ) {
142
+ return ;
143
+ }
144
+ // Process escape sequences
145
+ let processedText = text
146
+ . replace ( / \\ n / g, '\n' )
147
+ . replace ( / \\ r / g, '\r' ) ;
148
+
149
+ // Process hex escape sequences (\xNN)
150
+ while ( true ) {
151
+ const match = processedText . match ( / \\ x ( [ 0 - 9 a - f A - F ] { 2 } ) / ) ;
152
+ if ( match === null || match . index === undefined || match . length < 2 ) {
153
+ break ;
154
+ }
155
+ processedText = processedText . slice ( 0 , match . index ) + String . fromCharCode ( parseInt ( match [ 1 ] , 16 ) ) + processedText . slice ( match . index + 4 ) ;
156
+ }
157
+
158
+ text = processedText ;
129
159
}
130
- const configurationResolverService = accessor . get ( IConfigurationResolverService ) ;
131
- const workspaceContextService = accessor . get ( IWorkspaceContextService ) ;
132
- const historyService = accessor . get ( IHistoryService ) ;
160
+
133
161
const activeWorkspaceRootUri = historyService . getLastActiveWorkspaceRoot ( instance . isRemote ? Schemas . vscodeRemote : Schemas . file ) ;
134
162
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? workspaceContextService . getWorkspaceFolder ( activeWorkspaceRootUri ) ?? undefined : undefined ;
135
163
const resolvedText = await configurationResolverService . resolveAsync ( lastActiveWorkspaceRoot , text ) ;
@@ -1007,7 +1035,7 @@ export function registerTerminalActions() {
1007
1035
registerTerminalAction ( {
1008
1036
id : TerminalCommandId . SendSequence ,
1009
1037
title : terminalStrings . sendSequence ,
1010
- f1 : false ,
1038
+ f1 : true ,
1011
1039
metadata : {
1012
1040
description : terminalStrings . sendSequence . value ,
1013
1041
args : [ {
0 commit comments