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

Fix autocomplete prefix for custom identifierRegexes #4919

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 19, 2022

  1. Fix autocomplete prefix for custom identifierRegexes

    Hi, Ace team! My team has been using a fork of Ace, and I'm hoping to
    merge some of our changes upstream so that we can return to using your
    official releases.
    
    The engineer who originally accomplished this work has long since
    departed my team, so forgive me for this somewhat rote transcription of
    his working notes.
    
    > This was sent upstream in ajaxorg#2352,
    > but closed because ajaxorg@fcebd0f
    > seemed to address the same issue.  That fix unfortunately does not
    > work as we need, and fails the behavior described in our test named
    > `test leading @ not duplicated on autocomplete`
    >
    > The root cause: Autocomplete prefix can be wrong for completions with
    > a custom identifierRegex because `Autocompleter.base` is computed
    > relative to a prefix computed for the default identifierRegex.
    
    Below, I reproduce the test my colleague referred to.
    
    ```
    'test leading @ not duplicated on autocomplete': function (test) {
        editor.setValue('');
        editor.navigateFileStart();
    
        var text = 'view: users { derived_table: { sql: @{;; } }';
        exec('insertstring', 1, text);
        editor.moveCursorTo(0, 38);
        editor.getValue();
    
        attachedSymbolsToSession(text, editor.session, { const: 'value' });
        editor.execCommand('startAutocomplete');
    
        var completion = editor.completer.completions.filtered.filter(function(completion) { return completion.caption === '@{const}'; });
        test.ok(completion[0]);
    
        editor.completer.insertMatch(completion[0]);
        test.equal(editor.getValue(), 'view: users { derived_table: { sql: @{const};; } }');
    
        test.done();
    },
    ```
    AprilArcus committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    e4e7582 View commit details
    Browse the repository at this point in the history