[PATCH] space on prompt bugfix

Oswald Buddenhagen ossi at kde.org
Sat May 21 18:07:48 UTC 2005


On Mon, Mar 21, 2005 at 09:19:34AM +0100, Jindrich Novy wrote:
> Hi mc-devel!
> 
> There's a bug I've been annoyed with for some time so I finally decided
> to fix it.
> 
> To reproduce:
> 1. start mc
> 2. go to some directory where you see some further subdirectories
> 3. press space once or for more times -> spaces will appear in the
> command prompt
> 4. try to go to some subdirectory by pressing enter on it or press enter
> on any *.c, *.mp3 file.
> 
> Results:
> You're unable to change a directory until you delete all spaces typed on
> command prompt and mc does nothing while you're pressing Enter.
> Furthermore you're unable to launch any application by tapping enter on
> *.c, *.mp3 files, etc.
> 
[...]
> Allows an user to type leading spaces on the command prompt, but when
> enter is pressed, it tests whether the user typed at least something
> except spaces. In case it finds only spaces, it deletes them from the
> command prompt and let the enter be further processed.

On Wed, Apr 27, 2005 at 11:24:06PM +0200, Leonard den Ottolander wrote:
> Any objections against me committing this patch? The "real command line"
> argument seems bogus, as a "real command line" would accept a "command"
> existing of only spaces but mc does not.
> 
> So can I commit this? I'll verify that it works first ;) , but the patch
> seems straight forward enough.
> 
there were no objections, so i suppose you forgot it. :)

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
-------------- next part --------------
--- mc-4.6.1-pre3/src/main.c.jn	2005-03-19 15:55:40.000000000 +0100
+++ mc-4.6.1-pre3/src/main.c	2005-03-19 17:04:10.000000000 +0100
@@ -1490,9 +1490,14 @@ midnight_callback (struct Dlg_head *h, d
 	if (parm == '\t')
 	    free_completions (cmdline);
 
-	if (parm == '\n' && cmdline->buffer[0]) {
-	    send_message ((Widget *) cmdline, WIDGET_KEY, parm);
-	    return MSG_HANDLED;
+	if (parm == '\n') {
+	    for (i = 0; cmdline->buffer[i] && cmdline->buffer[i] == ' '; i++);
+	    if (cmdline->buffer[i]) {
+	        send_message ((Widget *) cmdline, WIDGET_KEY, parm);
+		return MSG_HANDLED;
+	    }
+	    stuff (cmdline, "", 0);
+	    cmdline->point = 0;
 	}
 
 	/* Ctrl-Enter and Alt-Enter */
@@ -1527,7 +1532,7 @@ midnight_callback (struct Dlg_head *h, d
 		    reverse_selection_cmd ();
 		    return MSG_HANDLED;
 		}
-	    } else if (!command_prompt || !strlen (cmdline->buffer)) {
+	    } else if (!command_prompt || !cmdline->buffer[0]) {
 		/* Special treatement '+', '-', '\', '*' only when this is 
 		 * first char on input line
 		 */


More information about the mc-devel mailing list