Skip to content

Commit e7a6b79

Browse files
committed
Allow indenting by pressing tab
1 parent 2220ed7 commit e7a6b79

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/shell.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl<'vm> RustylineReadline<'vm> {
106106
let mut repl = Editor::with_config(
107107
Config::builder()
108108
.completion_type(CompletionType::List)
109+
.tab_stop(4)
109110
.build(),
110111
);
111112
repl.set_helper(Some(ShellHelper::new(vm, scope)));

src/shell/rustyline_helper.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ impl Completer for ShellHelper<'_> {
155155
if pos != line.len() {
156156
return Ok((0, vec![]));
157157
}
158-
Ok(self.complete_opt(line).unwrap_or((0, vec![])))
158+
Ok(self
159+
.complete_opt(line)
160+
// as far as I can tell, there's no better way to do both completion
161+
// and indentation (or even just indentation)
162+
.unwrap_or_else(|| (line.len(), vec![" ".to_string()])))
159163
}
160164
}
161165

0 commit comments

Comments
 (0)