@@ -256,7 +256,9 @@ export class CommandManager {
256
256
let lineY = this . #activeCommand. promptEndMarker ! . line ;
257
257
let line = this . #terminal. buffer . active . getLine ( this . #activeCommand. promptEndMarker ! . line ) ;
258
258
let command = "" ;
259
+ let wrappedCommand = "" ;
259
260
let suggestions = "" ;
261
+ let isWrapped = false ;
260
262
for ( ; ; ) {
261
263
for ( let i = lineY == this . #activeCommand. promptEndMarker ! . line ? this . #activeCommand. promptText . length : 0 ; i < this . #terminal. cols ; i ++ ) {
262
264
if ( command . endsWith ( " " ) ) break ; // assume that a command that ends with 4 spaces is terminated, avoids capturing right prompts
@@ -266,19 +268,27 @@ export class CommandManager {
266
268
const cleanedChars = chars == "" ? " " : chars ;
267
269
if ( ! this . _isSuggestion ( cell ) && suggestions . length == 0 ) {
268
270
command += cleanedChars ;
271
+ wrappedCommand += cleanedChars ;
269
272
} else {
270
273
suggestions += cleanedChars ;
271
274
}
272
275
}
273
276
lineY += 1 ;
274
277
line = this . #terminal. buffer . active . getLine ( lineY ) ;
275
- if ( ! line ?. isWrapped ) {
278
+
279
+ const wrapped = line ?. isWrapped || this . #terminal. buffer . active . cursorY + this . #terminal. buffer . active . baseY != lineY - 1 ;
280
+ isWrapped = isWrapped || wrapped ;
281
+
282
+ if ( ! wrapped ) {
276
283
break ;
277
284
}
285
+ wrappedCommand = "" ;
278
286
}
279
287
280
- const cursorAtEndOfInput =
281
- ( this . #activeCommand. promptText . length + command . trimEnd ( ) . length ) % this . #terminal. cols <= this . #terminal. buffer . active . cursorX ;
288
+ const cursorAtEndOfInput = isWrapped
289
+ ? wrappedCommand . trim ( ) . length % this . #terminal. cols <= this . #terminal. buffer . active . cursorX
290
+ : ( this . #activeCommand. promptText . length + command . trimEnd ( ) . length ) % this . #terminal. cols <= this . #terminal. buffer . active . cursorX ;
291
+
282
292
let hasOutput = false ;
283
293
284
294
let cell = undefined ;
@@ -291,7 +301,11 @@ export class CommandManager {
291
301
}
292
302
}
293
303
294
- const commandPostfix = this . #activeCommand. promptText . length + command . trimEnd ( ) . length < this . #terminal. buffer . active . cursorX ? " " : "" ;
304
+ const postfixActive = isWrapped
305
+ ? wrappedCommand . trim ( ) . length < this . #terminal. buffer . active . cursorX
306
+ : this . #activeCommand. promptText . length + command . trimEnd ( ) . length < this . #terminal. buffer . active . cursorX ;
307
+
308
+ const commandPostfix = postfixActive ? " " : "" ;
295
309
this . #activeCommand. persistentOutput = this . #activeCommand. hasOutput && hasOutput ;
296
310
this . #activeCommand. hasOutput = hasOutput ;
297
311
this . #activeCommand. suggestionsText = suggestions . trim ( ) ;
0 commit comments