aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-08-09 10:17:49 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-08-09 10:17:49 +0200
commitcef8f2a7448a16867771222ed5aeddfab7ab8f54 (patch)
tree5fc4e965d8bffb7013523b2cbf957c730cf25197
parent8cb0071c7a42c1b2a436a97a401f1fefb07768c6 (diff)
downloadvis-cef8f2a7448a16867771222ed5aeddfab7ab8f54.tar.gz
vis-cef8f2a7448a16867771222ed5aeddfab7ab8f54.tar.xz
vis: fix :edit! command
It now correctly re-edits the file (i.e reloads it from disk).
-rw-r--r--editor.c11
-rw-r--r--vis.c5
2 files changed, 10 insertions, 6 deletions
diff --git a/editor.c b/editor.c
index c94e9be..e06e946 100644
--- a/editor.c
+++ b/editor.c
@@ -42,10 +42,13 @@ void editor_windows_arrange(Editor *ed, enum UiLayout layout) {
}
bool editor_window_reload(Win *win) {
- /* can't reload unsaved file */
- if (!win->file->name)
- return false;
- File *file = file_new(win->editor, win->file->name);
+ const char *name = win->file->name;
+ if (!name)
+ return false; /* can't reload unsaved file */
+ /* temporarily unset file name, otherwise file_new returns the same File */
+ win->file->name = NULL;
+ File *file = file_new(win->editor, name);
+ win->file->name = name;
if (!file)
return false;
file_free(win->editor, win->file);
diff --git a/vis.c b/vis.c
index 1648fa4..c263a6c 100644
--- a/vis.c
+++ b/vis.c
@@ -1812,8 +1812,9 @@ static bool cmd_edit(Filerange *range, enum CmdOpt opt, const char *argv[]) {
return editor_window_reload(oldwin);
if (!openfiles(&argv[1]))
return false;
- editor_window_close(oldwin);
- return true;
+ if (vis->win != oldwin)
+ editor_window_close(oldwin);
+ return vis->win != oldwin;
}
static bool cmd_quit(Filerange *range, enum CmdOpt opt, const char *argv[]) {