diff options
author | Mark Lumsden <lum@cvs.openbsd.org> | 2015-09-21 06:59:55 +0000 |
---|---|---|
committer | Mark Lumsden <lum@cvs.openbsd.org> | 2015-09-21 06:59:55 +0000 |
commit | 274856bf8f00a3665c48d9a3a8a51e3bc40479cf (patch) | |
tree | e0b07fae0be41b974d642c4f1ea1d75129341c9a /usr.bin | |
parent | 663851d5614d352491896f12c6a67f1fc13f0651 (diff) |
If you open the same directory twice in dired mode, mg does not behave
correctly. In effect what should happen is the existing dired buffer
is brought to the fore, and if the directory contents has changed
inform the user.
ok sunil@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/dired.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c index 54e042bcf3f..50cab3f9dfd 100644 --- a/usr.bin/mg/dired.c +++ b/usr.bin/mg/dired.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dired.c,v 1.72 2015/09/14 16:37:19 lum Exp $ */ +/* $OpenBSD: dired.c,v 1.73 2015/09/21 06:59:54 lum Exp $ */ /* This file is in the public domain. */ @@ -802,13 +802,16 @@ dired_(char *dname) } return (NULL); } - if ((bp = findbuffer(dname)) == NULL) { - dobeep(); - ewprintf("Could not create buffer"); - return (NULL); + for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { + if (strcmp(bp->b_fname, dname) == 0) { + if (fchecktime(bp) != TRUE) + ewprintf("Directory has changed on disk;" + " type g to update Dired"); + return (bp); + } + } - if (bclear(bp) != TRUE) - return (NULL); + bp = bfind(dname, TRUE); bp->b_flag |= BFREADONLY | BFIGNDIRTY; if ((d_exec(2, bp, NULL, "ls", "-al", dname, NULL)) != TRUE) @@ -841,6 +844,7 @@ dired_(char *dname) ewprintf("Could not find mode dired"); return (NULL); } + (void)fupdstat(bp); bp->b_nmodes = 1; return (bp); } |