Skip to content

Make bracket matching more robust for typeahead #304

Open
@dingfeli

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions