aboutsummaryrefslogtreecommitdiffstats
path: root/jsre/completion.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-02-20 21:58:06 +0800
committerFelix Lange <fjl@twurst.com>2016-04-13 18:06:42 +0800
commitf08680985a479482356192ee3b36f09a8ed3cb4c (patch)
treee59567874cc34e3029243278037ef863db4f2810 /jsre/completion.go
parent5542b51b5047ebd4792cd6b2cec789189c019e3c (diff)
downloaddexon-f08680985a479482356192ee3b36f09a8ed3cb4c.tar
dexon-f08680985a479482356192ee3b36f09a8ed3cb4c.tar.gz
dexon-f08680985a479482356192ee3b36f09a8ed3cb4c.tar.bz2
dexon-f08680985a479482356192ee3b36f09a8ed3cb4c.tar.lz
dexon-f08680985a479482356192ee3b36f09a8ed3cb4c.tar.xz
dexon-f08680985a479482356192ee3b36f09a8ed3cb4c.tar.zst
dexon-f08680985a479482356192ee3b36f09a8ed3cb4c.zip
jsre: fix <tab><tab> completion magic
Diffstat (limited to 'jsre/completion.go')
-rw-r--r--jsre/completion.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/jsre/completion.go b/jsre/completion.go
index 11e209b69..7f94dabfc 100644
--- a/jsre/completion.go
+++ b/jsre/completion.go
@@ -55,9 +55,18 @@ func getCompletions(vm *otto.Otto, line string) (results []string) {
}
}
})
- // e.g. web3<tab><tab> append dot since its an object
- if obj, _ = vm.Object(line); obj != nil {
- results = append(results, line+".")
+
+ // Append opening parenthesis (for functions) or dot (for objects)
+ // if the line itself is the only completion.
+ if len(results) == 1 && results[0] == line {
+ obj, _ := vm.Object(line)
+ if obj != nil {
+ if obj.Class() == "Function" {
+ results[0] += "("
+ } else {
+ results[0] += "."
+ }
+ }
}
sort.Strings(results)