chzyer / readline

Readline is a pure go(golang) implementation for GNU-Readline kind library
MIT License
2.1k stars 280 forks source link

How to not append space? #239

Open vczyh opened 2 months ago

vczyh commented 2 months ago
// "schema." is PcItemDynamic callback returned.
SELECT * FROM schema.
SELECT * FROM schema. table

I know the result is right. Every autocompletion will add space.

I want:

SELECT * FROM schema.table

What should I do?

Thanks!

wader commented 2 months ago

Could you post a minimal example that reproduces it? it should be possible, ex i use readline for fq and this works:

$ fq -i
null> {a:{b:123}} | .<tab><tab><tab>
# end up with
null> {a:{b:123}} | .a.b

BTW you might want to consider using https://github.com/ergochat/readline that is more active fork.

vczyh commented 2 months ago

Could you post a minimal example that reproduces it? it should be possible, ex i use readline for fq and this works:

$ fq -i
null> {a:{b:123}} | .<tab><tab><tab>
# end up with
null> {a:{b:123}} | .a.b

BTW you might want to consider using https://github.com/ergochat/readline that is more active fork.

fq custom AutoCompleter : https://github.com/wader/fq/blob/f150085735e8c20b86fa68210ed4162a3b6177b3/pkg/interp/interp.go#L458-L498

wader commented 2 months ago

Yeap ends up being used here https://github.com/wader/fq/blob/f150085735e8c20b86fa68210ed4162a3b6177b3/pkg/cli/cli.go#L200-L212

What do you use now? something like PrefixCompleter? that one seems to append whitespaces in some cases. Is there some reason you can't do your own AutoCompleter?

vczyh commented 2 months ago

Yeap ends up being used here https://github.com/wader/fq/blob/f150085735e8c20b86fa68210ed4162a3b6177b3/pkg/cli/cli.go#L200-L212

What do you use now? something like PrefixCompleter? that one seems to append whitespaces in some cases. Is there some reason you can't do your own AutoCompleter?

You're right. I need to implement my own AtutoCompleter. Thank you bro, I love you.

wader commented 2 months ago

Happy it helped 👍