@@ -31,6 +31,78 @@ public void EndOfLine()
3131 ) ) ;
3232 }
3333
34+ [ SkippableFact ]
35+ public void MultilineCursorMovement_WithWrappedLines ( )
36+ {
37+ TestSetup ( KeyMode . Cmd ) ;
38+
39+ int continutationPromptLength = PSConsoleReadLineOptions . DefaultContinuationPrompt . Length ;
40+ string line_0 = "4444" ;
41+ string line_1 = "33" ;
42+ string line_2 = "666666" ;
43+ string line_3 = "777" ;
44+
45+ int wrappedLength_1 = 9 ;
46+ int wrappedLength_2 = 2 ;
47+ string wrappedLine_1 = new string ( '8' , _console . BufferWidth - continutationPromptLength + wrappedLength_1 ) ; // Take 2 physical lines
48+ string wrappedLine_2 = new string ( '6' , _console . BufferWidth - continutationPromptLength + wrappedLength_2 ) ; // Take 2 physical lines
49+
50+ Test ( "" , Keys (
51+ "" , _ . Shift_Enter , // physical line 0
52+ line_0 , _ . Shift_Enter , // physical line 1
53+ line_1 , _ . Shift_Enter , // physical line 2
54+ line_2 , _ . Shift_Enter , // physical line 3
55+ wrappedLine_1 , _ . Shift_Enter , // physical line 4,5
56+ wrappedLine_2 , _ . Shift_Enter , // physical line 6,7
57+ line_3 , // physical line 8
58+
59+ // Starting at the end of the last line.
60+ // Verify that UpArrow goes to the end of the previous logical line.
61+ CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_3 . Length , 8 ) ) ,
62+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_3 . Length , 8 ) ) ,
63+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_3 . Length , 8 ) ) ,
64+ // Press Up/Down/Up
65+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( wrappedLength_2 , 7 ) ) ,
66+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_3 . Length , 8 ) ) ,
67+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( wrappedLength_2 , 7 ) ) ,
68+ // Press Up/Down/Up
69+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( wrappedLength_1 , 5 ) ) ,
70+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( wrappedLength_2 , 7 ) ) ,
71+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( wrappedLength_1 , 5 ) ) ,
72+ // Press Up/Down/Up
73+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_2 . Length , 3 ) ) ,
74+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( wrappedLength_1 , 5 ) ) ,
75+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_2 . Length , 3 ) ) ,
76+ // Press Up/Up
77+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_1 . Length , 2 ) ) ,
78+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length , 1 ) ) ,
79+
80+ // Move to left for 1 character, so the cursor now is not at the end of line.
81+ // Verify that DownArrow/UpArrow goes to the previous logical line at the same column.
82+ _ . LeftArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 1 ) ) ,
83+ // Press Down all the way to the end
84+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_1 . Length , 2 ) ) ,
85+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 3 ) ) ,
86+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 4 ) ) ,
87+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 5 ) ) ,
88+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 6 ) ) ,
89+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( wrappedLength_2 , 7 ) ) ,
90+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_3 . Length , 8 ) ) ,
91+ _ . DownArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_3 . Length , 8 ) ) ,
92+ // Press Up all the way to the physical line 1
93+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( wrappedLength_2 , 7 ) ) ,
94+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 6 ) ) ,
95+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 5 ) ) ,
96+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 4 ) ) ,
97+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 3 ) ) ,
98+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_1 . Length , 2 ) ) ,
99+ _ . UpArrow , CheckThat ( ( ) => AssertCursorLeftTopIs ( continutationPromptLength + line_0 . Length - 1 , 1 ) ) ,
100+
101+ // Clear the input, we were just testing movement
102+ _ . Escape
103+ ) ) ;
104+ }
105+
34106 [ SkippableFact ]
35107 public void MultilineCursorMovement ( )
36108 {
0 commit comments