Skip to content

documentation for REPL completion is somewhat obscure #3674

Closed

Description

@kapouer

On tab completion - eval will be called with .scope as an input string. It is expected to return an array of scope names to be used for the auto-completion.

that doesn't mean much...

Activity

  1. added
    docIssues and PRs related to Node.js documentation.
    replIssues and PRs related to the REPL subsystem.
    on Nov 5, 2015
  2. kapouer commented on Nov 5, 2015

    @kapouer
    ContributorAuthor

    Of course the obvious interpretation is

    repl.start({
        eval: function(cmd, context, filename, cb) {
            if (cmd == ".scope") {
                return cb(null, ["array", "of", "strings"]);
            }
            inst.run(cmd, cb);
        }
    });
    

    yet i don't think my eval function is ever called with that cmd argument being equal to ".scope" ?
    Anyway i don't get it.

  3. bnoordhuis commented on Nov 5, 2015

    @bnoordhuis
    Member

    yet i don't think my eval function is ever called with that cmd argument being equal to ".scope" ?

    That's #3544 (comment) - I couldn't make it work either.

  4. Fishrock123 commented on Nov 5, 2015

    @Fishrock123
    Contributor

    I'll keep it on my radar, but I don't think I'll get to looking at it soon.

  5. udnisap commented on Nov 25, 2015

    @udnisap

    Looks like the tab completion is called when it has a object ending with a .

    For example try this

    var _ = require('lodash');
    var repl = require('repl');
    
    var replServer = repl.start({});
    replServer.eval = _.wrap(replServer.eval, function(eval, cmd, context, filename, callback) {
        console.warn('eval with:', arguments);
        arguments[4] = _.wrap(callback, function(resultCallback){
            console.warn('result callbackdata:', arguments);
            resultCallback.apply(this, Array.prototype.slice.call(arguments, 1));
        });
        eval.apply(this, Array.prototype.slice.call(arguments, 1));
    });

    and run on the repl

    >Array.<tab>
    

    On tab completion - eval will be called with .scope as an input string. It is expected to return an array of scope names to be used for the auto-completion.

    means that if an object in the scope is in the promt with an ending . and user press on tab, eval is called with the object without the .

    node implementation is at https://github.com/nodejs/node/blob/v5.x/lib/repl.js

  6. Trott commented on Jun 8, 2016

    @Trott
    Member

    The offending text doesn't appear to be in the REPL docs anymore. I'm going to close this. Please comment or re-open if there's something I'm misunderstanding.

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

    docIssues and PRs related to Node.js documentation.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions