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

Make bracket matching more robust for typeahead #304

Open
dingfeli opened this issue Dec 9, 2024 · 0 comments
Open

Make bracket matching more robust for typeahead #304

dingfeli opened this issue Dec 9, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dingfeli
Copy link
Contributor

dingfeli commented Dec 9, 2024

Currently, the mechanism in typeahead for bracket matching is rather rudimentary:

private static boolean isCloseBracket(final String input, final int idx,
final Stack<QInlineSuggestionOpenBracketSegment> unresolvedBrackets) {
char c = input.charAt(idx);
boolean isBracket = c == ')' || c == ']' || c == '}' || c == '>' || c == '"' || c == '\'';
if (!isBracket) {
return false;
}
if (c == '"' || c == '\'') {
return !unresolvedBrackets.isEmpty() && unresolvedBrackets.peek().getSymbol() == c;
}
// TODO: enrich this check to eliminate false positives
if (idx > 0 && Character.isWhitespace(input.charAt(idx - 1)) && c == '>') {
return false;
}
return true;
}

As a result, the typeahead session is susceptible to having erroneously assess whether or not a character is a part of a bracket pair.

We need a more robust mechanism to parse the suggestion text to provide a more accurate typeahead experience.

@dingfeli dingfeli added the enhancement New feature or request label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant