vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit e724f0fa3826d9cb7bf85120583193e9163be0ce parent 6d0e6821163d8770929534539dfaba7a9eadfbc5 Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 29 Nov 2016 12:06:01 +0100 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. Diffstat:
| M | vis-cmds.c | | | 7 | ++++++- |
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git 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) {