Skip to content

Commit d250240

Browse files
javier-godoypaodb
authored andcommitted
revert: fix: fix selection feature because of XTerm bug
Revert commit 77ce362. EOL is no longer included when selecting multiple lines (xtermjs/xterm.js#3583) Close #39
1 parent 1abe682 commit d250240

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/main/resources/META-INF/frontend/fc-xterm/xterm-selection-mixin.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,12 @@ 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();
129-
130-
//see https://github.com/xtermjs/xterm.js/issues/3552
131-
pos.endColumn==0 && --pos.endRow;
132-
128+
let pos = terminal.getSelectionPosition();
133129
if (pos && pos.startRow>=range.first && pos.endRow<=range.last) {
130+
//let selectionStart = pos.startRow * terminal.cols + pos.startColumn;
134131
if (!this.__selectionRight) {
135132
//cursor backward wrapped
136-
if (pos.endColumn==0) {
137-
terminal.write("\x1b[<" + (this.__selectionLength-1) + "L");
138-
} else {
139-
terminal.write("\x1b[<" + this.__selectionLength + "L");
140-
}
133+
terminal.write("\x1b[<" + this.__selectionLength + "L");
141134
}
142135
//delete characters wrapped
143136
terminal.write("\x1b[<" + this.__selectionLength + "D");

src/test/java/com/flowingcode/vaadin/addons/xterm/integration/SelectionFeatureIT.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ public void testSelectionFeature() throws InterruptedException {
9898
term.write(text);
9999
assertThat(term.currentLine(), is(text));
100100
term.sendKeys(Keys.SHIFT, Keys.HOME);
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"));
101+
assertThat(term.getSelection(), is(text));
104102
term.sendKeys(Keys.DELETE);
105103
assertThat(term.currentLine(), isEmptyString());
106104

@@ -109,9 +107,10 @@ public void testSelectionFeature() throws InterruptedException {
109107
assertThat(term.currentLine(), is(text));
110108
term.sendKeys(Keys.HOME);
111109
term.sendKeys(Keys.SHIFT, Keys.END);
112-
assertThat(term.getSelection(), is(text + "\n"));
110+
assertThat(term.getSelection(), is(text));
113111
term.sendKeys(Keys.DELETE);
114112
assertThat(term.currentLine(), isEmptyString());
113+
115114
}
116115

117116
}

0 commit comments

Comments
 (0)