Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer isn't cleared properly when quotes are involved #1036

Open
HolyMolyCowMan opened this issue Jul 15, 2024 · 1 comment
Open

Buffer isn't cleared properly when quotes are involved #1036

HolyMolyCowMan opened this issue Jul 15, 2024 · 1 comment

Comments

@HolyMolyCowMan
Copy link

It would seem that when the input to a completer includes a double quote character as the first character and there are multiple completion candidates, the parser doesn't correctly remove the quote before adding the beginning and end quote back in. This leads to 3 quote characters instead of 2.

This happens when using the default parser & highlighter and built in completers as shown in the below snippet. Entering "Ex and then pressing tab would lead to ""Example1" as the output.

reader = LineReaderBuilder.builder().parser(new DefaultParser())
				.completer(new StringsCompleter("Example1", "Example2")).highlighter(new DefaultHighlighter())
				.terminal(terminal).build();

		reader.setOpt(Option.MENU_COMPLETE); // Show completion options as menu
		reader.unsetOpt(Option.CASE_INSENSITIVE);

		// Create auto-suggestion widgets and enable it
		AutosuggestionWidgets autosuggestionWidgets = new AutosuggestionWidgets(reader);
		autosuggestionWidgets.enable();

I have also had this happen when there are quotes at the beginning and the end, leading to part of the string being included too. "Example" and then pressing tab would lead to "EExample1.

@gnodet
Copy link
Member

gnodet commented Sep 11, 2024

Could you double check if that happens on other kind of terminals ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants