@@ -256,7 +256,9 @@ export class CommandManager {
256256 let lineY = this . #activeCommand. promptEndMarker ! . line ;
257257 let line = this . #terminal. buffer . active . getLine ( this . #activeCommand. promptEndMarker ! . line ) ;
258258 let command = "" ;
259+ let wrappedCommand = "" ;
259260 let suggestions = "" ;
261+ let isWrapped = false ;
260262 for ( ; ; ) {
261263 for ( let i = lineY == this . #activeCommand. promptEndMarker ! . line ? this . #activeCommand. promptText . length : 0 ; i < this . #terminal. cols ; i ++ ) {
262264 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 {
266268 const cleanedChars = chars == "" ? " " : chars ;
267269 if ( ! this . _isSuggestion ( cell ) && suggestions . length == 0 ) {
268270 command += cleanedChars ;
271+ wrappedCommand += cleanedChars ;
269272 } else {
270273 suggestions += cleanedChars ;
271274 }
272275 }
273276 lineY += 1 ;
274277 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 ) {
276283 break ;
277284 }
285+ wrappedCommand = "" ;
278286 }
279287
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+
282292 let hasOutput = false ;
283293
284294 let cell = undefined ;
@@ -291,7 +301,11 @@ export class CommandManager {
291301 }
292302 }
293303
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 ? " " : "" ;
295309 this . #activeCommand. persistentOutput = this . #activeCommand. hasOutput && hasOutput ;
296310 this . #activeCommand. hasOutput = hasOutput ;
297311 this . #activeCommand. suggestionsText = suggestions . trim ( ) ;
0 commit comments