aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-03-23 04:21:39 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-03-23 04:36:37 +0300
commite066864eb3a468b64970107e880a2f3e16d67a37 (patch)
tree720e192976a6e610cf233521e08645a3a8e3b3a9 /src/cmdline.c
parent064f05f7f651f84fe31b4d65eefac22b80309190 (diff)
downloadsciteco-e066864eb3a468b64970107e880a2f3e16d67a37.tar.gz
the ^W immediate editing command now mimics `Y` more closely and also rubs out no-op commands (whitespace)
* In string arguments, ^W first rubs out non-word chars (usually whitespace), so it makes sense if ^W would work analogously at the command level. A non-command would be one of the no-ops.
Diffstat (limited to 'src/cmdline.c')
-rw-r--r--src/cmdline.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/cmdline.c b/src/cmdline.c
index b3da887..25b7b98 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -449,6 +449,11 @@ teco_state_process_edit_cmd(teco_machine_t *ctx, teco_machine_t *parent_ctx, gun
case TECO_CTL_KEY('W'): /* rubout/reinsert command */
teco_interface_popup_clear();
+ /*
+ * This mimics the behavior of the `Y` command,
+ * so it also rubs out no-op commands.
+ * See also teco_find_words().
+ */
if (teco_cmdline.modifier_enabled) {
/* reinsert command */
do {
@@ -456,12 +461,26 @@ teco_state_process_edit_cmd(teco_machine_t *ctx, teco_machine_t *parent_ctx, gun
return FALSE;
} while (!ctx->current->is_start &&
teco_cmdline.effective_len < teco_cmdline.str.len);
- } else {
- /* rubout command */
- do
- teco_cmdline_rubout();
- while (!ctx->current->is_start);
+
+ while (ctx->current->is_start &&
+ teco_cmdline.effective_len < teco_cmdline.str.len &&
+ strchr(TECO_NOOPS, teco_cmdline.str.data[teco_cmdline.effective_len]))
+ if (!teco_cmdline_rubin(error))
+ return FALSE;
+
+ return TRUE;
}
+
+ /* rubout command */
+ while (ctx->current->is_start &&
+ teco_cmdline.effective_len > 0 &&
+ strchr(TECO_NOOPS, teco_cmdline.str.data[teco_cmdline.effective_len-1]))
+ teco_cmdline_rubout();
+
+ do
+ teco_cmdline_rubout();
+ while (!ctx->current->is_start);
+
return TRUE;
#if !defined(INTERFACE_GTK) && defined(SIGTSTP)