Skip to content

Commit edcf814

Browse files
javier-godoymlopezFC
authored andcommitted
chore: remove support for page up/down history navigation
1 parent fa80d3d commit edcf814

File tree

2 files changed

+0
-67
lines changed

2 files changed

+0
-67
lines changed

src/main/java/com/flowingcode/vaadin/addons/xterm/TerminalHistory.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public class TerminalHistory implements Serializable {
2828

2929
private List<Registration> registrations;
3030

31-
private String prefix;
32-
3331
private String lastRet;
3432

3533
private String initialLine;
@@ -84,8 +82,6 @@ public void setEnabled(boolean enabled) {
8482
registrations.add(((ITerminalConsole) terminal).addLineListener(ev -> add(ev.getLine())));
8583
registrations.add(terminal.addCustomKeyListener(ev -> handleArrowUp(), Key.ARROW_UP));
8684
registrations.add(terminal.addCustomKeyListener(ev -> handleArrowDown(), Key.ARROW_DOWN));
87-
registrations.add(terminal.addCustomKeyListener(ev -> handlePageUp(), Key.PAGE_UP));
88-
registrations.add(terminal.addCustomKeyListener(ev -> handlePageDown(), Key.PAGE_DOWN));
8985
}
9086
}
9187

@@ -109,15 +105,6 @@ private void handleArrowDown() {
109105
write(next());
110106
}
111107

112-
private void handlePageUp() {
113-
((ITerminalConsole) terminal).getCurrentLine().thenApply(this::findPrevious)
114-
.thenAccept(this::write);
115-
}
116-
117-
private void handlePageDown() {
118-
((ITerminalConsole) terminal).getCurrentLine().thenApply(this::findNext)
119-
.thenAccept(this::write);
120-
}
121108

122109
private void write(String line) {
123110
if (line != null) {
@@ -168,14 +155,6 @@ public void add(String line) {
168155
}
169156
}
170157

171-
private void setCurrentLine(String currentLine) {
172-
if (!currentLine.equals(lastRet)) {
173-
initialLine = currentLine;
174-
prefix = currentLine;
175-
iterator = null;
176-
}
177-
}
178-
179158
private Optional<String> find(Iterator<String> iterator, Predicate<String> predicate) {
180159
while (iterator.hasNext()) {
181160
String line = iterator.next();
@@ -198,16 +177,6 @@ private String next() {
198177
});
199178
}
200179

201-
private String findPrevious(String currentLine) {
202-
setCurrentLine(currentLine);
203-
return find(reverseIterator(), line -> line.startsWith(prefix)).orElse(null);
204-
}
205-
206-
private String findNext(String currentLine) {
207-
setCurrentLine(currentLine);
208-
return find(forwardIterator(), line -> line.startsWith(prefix)).orElse("");
209-
}
210-
211180
/** Clears the history. */
212181
public void clear() {
213182
history.clear();

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

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,40 +61,4 @@ public void testArrowKeysAndRestore() {
6161
assertThat(currentLine(term), is("bar"));
6262
}
6363

64-
@Test
65-
public void testPageUpDown() {
66-
TestBenchElement term = $("fc-xterm").first();
67-
68-
WebElement input = (WebElement) waitUntil(driver -> ((HasTestBenchCommandExecutor) driver)
69-
.getCommandExecutor().executeScript("return arguments[0].terminal.textarea", term));
70-
71-
int y = cursorPosition(term).y;
72-
input.sendKeys("foo1\nfoo2\nbar1\nfoo3\n");
73-
74-
assertThat(cursorPosition(term), is(at(0, y += 4)));
75-
assertThat(lineAtOffset(term, 0), isEmptyString());
76-
77-
input.sendKeys("f", Keys.PAGE_UP);
78-
assertThat(currentLine(term), is("foo3"));
79-
80-
input.sendKeys(Keys.PAGE_UP);
81-
assertThat(currentLine(term), is("foo2"));
82-
83-
input.sendKeys(Keys.PAGE_UP);
84-
assertThat(currentLine(term), is("foo1"));
85-
86-
input.sendKeys(Keys.PAGE_UP);
87-
assertThat(currentLine(term), is("foo1"));
88-
89-
input.sendKeys(Keys.PAGE_DOWN);
90-
assertThat(currentLine(term), is("foo2"));
91-
92-
input.sendKeys(Keys.PAGE_DOWN);
93-
assertThat(currentLine(term), is("foo3"));
94-
95-
input.sendKeys(Keys.PAGE_DOWN);
96-
assertThat(currentLine(term), isEmptyString());
97-
98-
}
99-
10064
}

0 commit comments

Comments
 (0)