diff options
-rw-r--r-- | qbuffers.cpp | 14 | ||||
-rw-r--r-- | qbuffers.h | 5 |
2 files changed, 12 insertions, 7 deletions
diff --git a/qbuffers.cpp b/qbuffers.cpp index 878194c..09888a4 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -113,14 +113,13 @@ QRegister::load(const gchar *filename) gchar *contents; gsize size; - current_save_dot(); - edit(); - dot = 0; - /* FIXME: prevent excessive allocations by reading file into buffer */ if (!g_file_get_contents(filename, &contents, &size, NULL)) return false; + edit(); + dot = 0; + interface.ssm(SCI_BEGINUNDOACTION); interface.ssm(SCI_CLEARALL); interface.ssm(SCI_APPENDTEXT, size, (sptr_t)contents); @@ -577,9 +576,10 @@ StateLoadQReg::done(const gchar *str) throw (Error) BEGIN_EXEC(&States::start); if (*str) { - undo.push_var<gint>(register_argument->dot); - undo.push_msg(SCI_UNDO); - register_argument->load(str); + register_argument->undo_load(); + if (!register_argument->load(str)) + throw Error("Cannot load \"%s\" into Q-Register \"%s\"", + str, register_argument->name); } else { if (ring.current) ring.undo_edit(); @@ -82,6 +82,11 @@ public: } bool load(const gchar *filename); + inline void + undo_load(void) + { + undo_set_string(); + } }; extern class QRegisterTable : public RBTree { |