gomacro icon indicating copy to clipboard operation
gomacro copied to clipboard

feature request: tab complete suggestions dropdown

Open sethgrid opened this issue 7 years ago • 3 comments

Right now, the tab complete requires that you tab through to see options. fmt.+tab,tab,tab,tab,shift+tab. That is a fantastic start. It would be even more awesome if a dropdown showed up or similar so you can see a list of autocomplete suggestions. Great for discoverability.

gomacro> fmt.Print<tab>
[Print Println Printf]

(with an underline on the current position, so underlined Print)

sethgrid avatar Jul 12 '18 17:07 sethgrid

I agree it would be useful, but AFAIK the line editing and code completion library github.com/peterh/liner currently used by gomacro does not support that.

If you have a suggestion for an alternative library with more features, you're welcome - it's something I'd rather not implement manually in gomacro...

cosmos72 avatar Jul 12 '18 17:07 cosmos72

The tcell golang lib might have something.

ghost avatar Jul 14 '18 11:07 ghost

You may modify line 62 in base/readline.go

from

func MakeTtyReadline(historyfile string) (TtyReadline, error) {
	tty := TtyReadline{liner.NewLiner()}

to

func MakeTtyReadline(historyfile string) (TtyReadline, error) {
	line := liner.NewLiner()
	line.SetTabCompletionStyle(liner.TabPrints)
	tty := TtyReadline{line}

This will make tab completion of github.com/peterh/liner behaves similar to BASH.

However, it's nowhere as good as a drop-down that's similar in IPython.

unavaliabl3 avatar Jun 13 '21 10:06 unavaliabl3