Commit Diff


commit - 135e1a5281c10f604143ac939828cc1e1a799949
commit + 16578ca54ffdaeb1dbb244f6577b18c9f52f8c03
blob - cf8ee063af57635327b4b4c997b5de67067dfa04
blob + dfb9fa0403e167d2d816568be139b7066340d45f
--- ChangeLog
+++ ChangeLog
@@ -1,4 +1,6 @@
 2022-01-02  Omar Polo  <op@omarpolo.com>
+
+	* minibuffer.c (eecmd_select): execute the selected command, not what it's being typed into the minibuffer.
 
 	* defaults.c (load_default_keys): bind `del' to previous-page.  Suggested by Florian.
 
blob - 4308a59fd694ab21128f3ab9d309afaa7a145492
blob + e826aa9b83a84f8316aeca93e18b098f9f0eae1b
--- cmd.c
+++ cmd.c
@@ -837,18 +837,10 @@ cmd_next_completion(struct buffer *buffer)
 void
 cmd_insert_current_candidate(struct buffer *buffer)
 {
-	struct vline *vl;
-
 	if (in_minibuffer != MB_COMPREAD)
-		return;
-
-	buffer = &ministate.compl.buffer;
-	if ((vl = buffer->current_line) == NULL)
 		return;
 
-	minibuffer_taint_hist();
-	strlcpy(ministate.buf, vl->parent->line, sizeof(ministate.buf));
-	ministate.buffer.cpoff = utf8_cplen(ministate.buf);
+	minibuffer_insert_current_candidate();
 }
 
 void
blob - 3fb0100b72f58b281acbced7b9fbfce4123c3842
blob + 1d8c0e73982110f78bbfa3da22ae02878591f112
--- minibuffer.c
+++ minibuffer.c
@@ -94,6 +94,22 @@ recompute_completions(int add)
 		vl->parent->type = LINE_COMPL_CURRENT;
 }
 
+int
+minibuffer_insert_current_candidate(void)
+{
+	struct vline *vl;
+
+	vl = ministate.compl.buffer.current_line;
+	if (vl == NULL || vl->parent->flags & L_HIDDEN)
+		return -1;
+
+	minibuffer_taint_hist();
+	strlcpy(ministate.buf, vl->parent->line, sizeof(ministate.buf));
+	ministate.buffer.cpoff = utf8_cplen(ministate.buf);
+
+	return 0;
+}
+
 static void *
 minibuffer_metadata(void)
 {
@@ -178,10 +194,18 @@ sensible_self_insert(void)
 void
 eecmd_select(void)
 {
-	struct cmd *cmd;
+	struct cmd	*cmd;
+	struct vline	*vl;
+	const char	*t;
+
+	vl = ministate.compl.buffer.current_line;
+	if (vl == NULL || vl->parent->flags & L_HIDDEN)
+		goto end;
 
+	t = vl->parent->line;
 	for (cmd = cmds; cmd->cmd != NULL; ++cmd) {
-		if (!strcmp(cmd->cmd, ministate.buf)) {
+		if (!strcmp(cmd->cmd, t)) {
+			minibuffer_insert_current_candidate();
 			exit_minibuffer();
 			minibuffer_hist_save_entry();
 			cmd->fn(current_buffer());
@@ -189,6 +213,7 @@ eecmd_select(void)
 		}
 	}
 
+end:
 	message("No match");
 }
 
blob - 1e74dc746a66be52c92177e1a5426143d470e617
blob + 4388609c5677976c7328ef4a22e25c32e4e72c1f
--- minibuffer.h
+++ minibuffer.h
@@ -69,7 +69,7 @@ extern struct buffer	 minibufferwin;
 extern int		 in_minibuffer;
 
 void	 recompute_completions(int);
-
+int	 minibuffer_insert_current_candidate(void);
 void	 minibuffer_taint_hist(void);
 void	 minibuffer_self_insert(void);
 void	 sensible_self_insert(void);