File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
main/resources/META-INF/frontend/fc-xterm
test/java/com/flowingcode/vaadin/addons/xterm/integration Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -125,12 +125,19 @@ class SelectionAddon extends TerminalAddon<ISelectionMixin> {
125125 if ( this . __selectionAnchor !== undefined ) {
126126 let buffer = ( terminal . buffer . active as any ) . _buffer ;
127127 let range = buffer . getWrappedRangeForLine ( buffer . ybase + buffer . y ) ;
128- let pos = terminal . getSelectionPosition ( ) ;
128+ let pos = terminal . getSelectionPosition ( ) ;
129+
130+ //see https://github.com/xtermjs/xterm.js/issues/3552
131+ pos . endColumn == 0 && -- pos . endRow ;
132+
129133 if ( pos && pos . startRow >= range . first && pos . endRow <= range . last ) {
130- //let selectionStart = pos.startRow * terminal.cols + pos.startColumn;
131134 if ( ! this . __selectionRight ) {
132135 //cursor backward wrapped
133- terminal . write ( "\x1b[<" + this . __selectionLength + "L" ) ;
136+ if ( pos . endColumn == 0 ) {
137+ terminal . write ( "\x1b[<" + ( this . __selectionLength - 1 ) + "L" ) ;
138+ } else {
139+ terminal . write ( "\x1b[<" + this . __selectionLength + "L" ) ;
140+ }
134141 }
135142 //delete characters wrapped
136143 terminal . write ( "\x1b[<" + this . __selectionLength + "D" ) ;
Original file line number Diff line number Diff line change @@ -98,7 +98,9 @@ public void testSelectionFeature() throws InterruptedException {
9898 term .write (text );
9999 assertThat (term .currentLine (), is (text ));
100100 term .sendKeys (Keys .SHIFT , Keys .HOME );
101- assertThat (term .getSelection (), is (text ));
101+ // https://github.com/xtermjs/xterm.js/issues/3552
102+ // Selecting a whole line using API includes trailing CRLF
103+ assertThat (term .getSelection (), is (text + "\n " ));
102104 term .sendKeys (Keys .DELETE );
103105 assertThat (term .currentLine (), isEmptyString ());
104106
@@ -107,10 +109,9 @@ public void testSelectionFeature() throws InterruptedException {
107109 assertThat (term .currentLine (), is (text ));
108110 term .sendKeys (Keys .HOME );
109111 term .sendKeys (Keys .SHIFT , Keys .END );
110- assertThat (term .getSelection (), is (text ));
112+ assertThat (term .getSelection (), is (text + " \n " ));
111113 term .sendKeys (Keys .DELETE );
112114 assertThat (term .currentLine (), isEmptyString ());
113-
114115 }
115116
116117}
You can’t perform that action at this time.
0 commit comments