@@ -19,7 +19,7 @@ class TestPromptInputModel extends PromptInputModel {
19
19
}
20
20
}
21
21
22
- suite ( 'PromptInputModel' , ( ) => {
22
+ suite . only ( 'PromptInputModel' , ( ) => {
23
23
const store = ensureNoDisposablesAreLeakedInTestSuite ( ) ;
24
24
let promptInputModel : TestPromptInputModel ;
25
25
let xterm : Terminal ;
@@ -40,6 +40,23 @@ suite('PromptInputModel', () => {
40
40
}
41
41
}
42
42
43
+ function assertPromptInput ( valueWithCursor : string ) {
44
+ if ( ! valueWithCursor . includes ( '|' ) ) {
45
+ throw new Error ( 'assertPromptInput must contain | character' ) ;
46
+ }
47
+ const actualValueWithCursor = promptInputModel . value . substring ( 0 , promptInputModel . cursorIndex ) + '|' + promptInputModel . value . substring ( promptInputModel . cursorIndex ) ;
48
+ strictEqual (
49
+ actualValueWithCursor . replaceAll ( '\n' , '\u23CE' ) ,
50
+ valueWithCursor . replaceAll ( '\n' , '\u23CE' )
51
+ ) ;
52
+
53
+ // This shouldn't be needed but include as a sanity check
54
+ const value = valueWithCursor . replace ( '|' , '' ) ;
55
+ const cursorIndex = valueWithCursor . indexOf ( '|' ) ;
56
+ strictEqual ( promptInputModel . value , value ) ;
57
+ strictEqual ( promptInputModel . cursorIndex , cursorIndex , ) ;
58
+ }
59
+
43
60
suite ( 'Windows, pwsh 7.4.2, starship prompt' , ( ) => {
44
61
test ( 'input with ignored ghost text' , async ( ) => {
45
62
await replayEvents ( [
@@ -52,7 +69,7 @@ suite('PromptInputModel', () => {
52
69
] ) ;
53
70
onCommandStart . fire ( { marker : xterm . registerMarker ( ) } as ITerminalCommand ) ;
54
71
promptInputModel . forceSync ( ) ;
55
- strictEqual ( promptInputModel . value , ' ') ;
72
+ assertPromptInput ( '| ') ;
56
73
57
74
await replayEvents ( [
58
75
'[?25l[93mf[97m[2m[3makecommand[3;4H[?25h' ,
@@ -63,8 +80,7 @@ suite('PromptInputModel', () => {
63
80
'[m' ,
64
81
] ) ;
65
82
promptInputModel . forceSync ( ) ;
66
- strictEqual ( promptInputModel . value , 'foo' ) ;
67
- strictEqual ( promptInputModel . cursorIndex , 3 ) ;
83
+ assertPromptInput ( 'foo|' ) ;
68
84
} ) ;
69
85
} ) ;
70
86
} ) ;
0 commit comments