Skip to content

Commit 6320514

Browse files
committed
Autocomplete REPL commands
1 parent 06fea5a commit 6320514

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/module/repl.wren

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ class Repl {
287287
// Only complete if the cursor is at the end.
288288
if (_cursor != _line.count) return null
289289

290+
if (Command.isCommand(_line)) {
291+
for (entry in COMMANDS) {
292+
var command = entry[0]
293+
var line = _line.trimStart()
294+
if (command.startsWith(line)) {
295+
return command[line.count..-1]
296+
}
297+
}
298+
}
299+
290300
for (name in Meta.getModuleVariables("repl")) {
291301
// TODO: Also allow completion if the line ends with an identifier but
292302
// has other stuff before it.

src/module/repl.wren.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,16 @@ static const char* replModuleSource =
289289
" // Only complete if the cursor is at the end.\n"
290290
" if (_cursor != _line.count) return null\n"
291291
"\n"
292+
" if (Command.isCommand(_line)) {\n"
293+
" for (entry in COMMANDS) {\n"
294+
" var command = entry[0]\n"
295+
" var line = _line.trimStart()\n"
296+
" if (command.startsWith(line)) {\n"
297+
" return command[line.count..-1]\n"
298+
" }\n"
299+
" }\n"
300+
" }\n"
301+
"\n"
292302
" for (name in Meta.getModuleVariables(\"repl\")) {\n"
293303
" // TODO: Also allow completion if the line ends with an identifier but\n"
294304
" // has other stuff before it.\n"

0 commit comments

Comments
 (0)