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

documentation for REPL completion is somewhat obscure #3674

Closed
kapouer opened this issue Nov 5, 2015 · 5 comments
Closed

documentation for REPL completion is somewhat obscure #3674

kapouer opened this issue Nov 5, 2015 · 5 comments
Labels
doc Issues and PRs related to the documentations. repl Issues and PRs related to the REPL subsystem.

Comments

@kapouer
Copy link
Contributor

kapouer commented Nov 5, 2015

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...

@mscdex mscdex added doc Issues and PRs related to the documentations. repl Issues and PRs related to the REPL subsystem. labels Nov 5, 2015
@kapouer
Copy link
Contributor Author

kapouer commented Nov 5, 2015

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.

@bnoordhuis
Copy link
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.

@Fishrock123
Copy link
Contributor

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

@udnisap
Copy link

udnisap commented Nov 25, 2015

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

@Trott
Copy link
Member

Trott commented Jun 8, 2016

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
Labels
doc Issues and PRs related to the documentations. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

6 participants