aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmdline.c')
-rw-r--r--src/cmdline.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/cmdline.c b/src/cmdline.c
index a4e2189..1abf8df 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -911,8 +911,28 @@ teco_state_insert_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *par
return stringbuilding_current->process_edit_cmd_cb(&stringbuilding_ctx->parent, &ctx->parent, key, error);
switch (key) {
- case '\t': { /* insert <TAB> indention */
+ case '\t': { /* insert <TAB> indention or auto complete */
+ if (teco_cmdline.modifier_enabled && !teco_qreg_current && teco_lsp_is_running()) {
+ if (teco_interface_popup_is_shown()) {
+ /* cycle through popup pages */
+ teco_interface_popup_scroll();
+ return TRUE;
+ }
+
+ g_auto(teco_string_t) new_chars, new_chars_escaped;
+ gboolean unambiguous = teco_lsp_buffer_auto_complete(teco_ring_current, &new_chars);
+ teco_machine_stringbuilding_escape(stringbuilding_ctx, new_chars.data,
+ new_chars.len, &new_chars_escaped);
+ if (unambiguous) {
+ teco_string_append_c(&new_chars_escaped, ' ');
+ teco_cmdline_modifier_set(FALSE);
+ }
+
+ return teco_cmdline_insert(new_chars_escaped.data, new_chars_escaped.len, error);
+ }
+
if (teco_cmdline.modifier_enabled || teco_interface_ssm(SCI_GETUSETABS, 0, 0))
+ /* perhaps auto-complete file name */
break;
teco_interface_popup_clear();