-/* $OpenBSD: exf.h,v 1.5 2015/04/24 21:48:31 brynet Exp $ */
+/* $OpenBSD: exf.h,v 1.6 2022/02/20 19:45:51 tb Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
#define F_RCV_NORM 0x020 /* Don't delete recovery files. */
#define F_RCV_ON 0x040 /* Recovery is possible. */
#define F_UNDO 0x080 /* No change since last undo. */
- u_int8_t flags;
+#define F_RCV_SYNC 0x100 /* Recovery file sync needed. */
+ u_int16_t flags;
};
/* Flags to db_get(). */
-/* $OpenBSD: line.c,v 1.15 2016/01/06 22:28:52 millert Exp $ */
+/* $OpenBSD: line.c,v 1.16 2022/02/20 19:45:51 tb Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
/* File now modified. */
if (F_ISSET(ep, F_FIRSTMODIFY))
(void)rcv_init(sp);
- F_SET(ep, F_MODIFIED);
+ F_SET(ep, F_MODIFIED | F_RCV_SYNC);
/* Update screen. */
return (scr_update(sp, lno, LINE_DELETE, 1));
/* File now dirty. */
if (F_ISSET(ep, F_FIRSTMODIFY))
(void)rcv_init(sp);
- F_SET(ep, F_MODIFIED);
+ F_SET(ep, F_MODIFIED | F_RCV_SYNC);
/* Log change. */
log_line(sp, lno + 1, LOG_LINE_APPEND);
/* File now dirty. */
if (F_ISSET(ep, F_FIRSTMODIFY))
(void)rcv_init(sp);
- F_SET(ep, F_MODIFIED);
+ F_SET(ep, F_MODIFIED | F_RCV_SYNC);
/* Log change. */
log_line(sp, lno, LOG_LINE_INSERT);
/* File now dirty. */
if (F_ISSET(ep, F_FIRSTMODIFY))
(void)rcv_init(sp);
- F_SET(ep, F_MODIFIED);
+ F_SET(ep, F_MODIFIED | F_RCV_SYNC);
/* Log after change. */
log_line(sp, lno, LOG_LINE_RESET_F);
-/* $OpenBSD: recover.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */
+/* $OpenBSD: recover.c,v 1.32 2022/02/20 19:45:51 tb Exp $ */
/*-
* Copyright (c) 1993, 1994
/* Sync the file if it's been modified. */
if (F_ISSET(ep, F_MODIFIED)) {
+ /* Clear recovery sync flag. */
+ F_CLR(ep, F_RCV_SYNC);
if (ep->db->sync(ep->db, R_RECNOSYNC)) {
F_CLR(ep, F_RCV_ON | F_RCV_NORM);
msgq_str(sp, M_SYSERR,
-/* $OpenBSD: ex.c,v 1.21 2016/03/19 00:21:28 mestre Exp $ */
+/* $OpenBSD: ex.c,v 1.22 2022/02/20 19:45:51 tb Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
msgq(sp, M_ERR, "Interrupted");
}
+ /* Sync recovery if changes were made. */
+ if (F_ISSET(sp->ep, F_RCV_SYNC))
+ rcv_sync(sp, 0);
+
/*
* If the last command caused a restart, or switched screens
* or into vi, return.
-/* $OpenBSD: vi.c,v 1.22 2019/01/24 15:09:41 millert Exp $ */
+/* $OpenBSD: vi.c,v 1.23 2022/02/20 19:45:51 tb Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
(void)sp->gp->scr_rename(sp, sp->frp->name, 1);
}
+ /* Sync recovery if changes were made. */
+ if (F_ISSET(sp->ep, F_RCV_SYNC))
+ rcv_sync(sp, 0);
+
/* If leaving vi, return to the main editor loop. */
if (F_ISSET(gp, G_SRESTART) || F_ISSET(sp, SC_EX)) {
*spp = sp;