Skip to content

Commit

Permalink
#533: Add autocompletion of exit in ide shell (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingAmeise authored Oct 26, 2024
1 parent 2024c35 commit b15bfdf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Release with new features and bugfixes:
* https://github.com/devonfw/IDEasy/issues/525[#525]: Added online state check before downloading
* https://github.com/devonfw/IDEasy/issues/663[#663]: Endless loop when installing Eclipse in force mode
* https://github.com/devonfw/IDEasy/issues/657[#657]: Cannot install Java 8
* https://github.com/devonfw/IDEasy/issues/533[#533]: Added autocompletion of exit in ide shell

The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/13?closed=1[milestone 2024.09.002].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import java.util.Iterator;

import org.fusesource.jansi.AnsiConsole;
import org.jline.reader.Completer;
import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.MaskingCallback;
import org.jline.reader.Parser;
import org.jline.reader.UserInterruptException;
import org.jline.reader.impl.DefaultParser;
import org.jline.reader.impl.completer.AggregateCompleter;
import org.jline.reader.impl.completer.StringsCompleter;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
import org.jline.widget.AutosuggestionWidgets;
Expand Down Expand Up @@ -65,8 +68,9 @@ public void run() {
Parser parser = new DefaultParser();
try (Terminal terminal = TerminalBuilder.builder().build()) {

// initialize our own completer here
IdeCompleter completer = new IdeCompleter((AbstractIdeContext) this.context);
// initialize our own completer here and add exit as an autocompletion option
Completer completer = new AggregateCompleter(
new StringsCompleter("exit"), new IdeCompleter((AbstractIdeContext) this.context));

LineReader reader = LineReaderBuilder.builder().terminal(terminal).completer(completer).parser(parser)
.variable(LineReader.LIST_MAX, AUTOCOMPLETER_MAX_RESULTS).build();
Expand All @@ -86,6 +90,10 @@ public void run() {
while (true) {
try {
line = reader.readLine(prompt, rightPrompt, (MaskingCallback) null, null);
line = line.trim();
if (line.equals("exit")) {
return;
}
reader.getHistory().add(line);
int rc = runCommand(line);
if (rc == RC_EXIT) {
Expand Down

0 comments on commit b15bfdf

Please sign in to comment.