aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-11-29 12:06:01 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-11-30 23:17:50 +0100
commite9dc79b5e43134bea9eb71f0827a881d86d0b560 (patch)
treec9b8fae3489232121e2134d0ab03d0c5f39981e5
parenta78dcbb09a27fa446dbe0a6bd36217dae46ec441 (diff)
downloadvis-e9dc79b5e43134bea9eb71f0827a881d86d0b560.tar.gz
vis-e9dc79b5e43134bea9eb71f0827a881d86d0b560.tar.xz
vis: avoid inconsistent state after file reloading with :e
When a file is opened in multiple windows we could end up in an inconsistent state by doing: $ vis some-file :spl :e At this point the two windows were referencing different file objects thus changes in one would not affect the other although they have the same path. Another option would be to reload all windows currently displaying the file being reloaded. We opt for the simpler fix for now.
-rw-r--r--vis-cmds.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/vis-cmds.c b/vis-cmds.c
index 11a92dc..18169f5 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -321,8 +321,13 @@ static bool cmd_edit(Vis *vis, Win *win, Command *cmd, const char *argv[], Curso
info_unsaved_changes(vis);
return false;
}
- if (!argv[1])
+ if (!argv[1]) {
+ if (oldwin->file->refcount > 1) {
+ vis_info_show(vis, "Can not reload file being opened multiple times");
+ return false;
+ }
return vis_window_reload(oldwin);
+ }
if (!openfiles(vis, &argv[1]))
return false;
if (vis->win != oldwin) {