summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-11-07 18:24:08 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-11-07 18:25:49 +0000
commit6840f7ce9cae76295ecedd92114829b413fdd6bb (patch)
tree2331ca711cf9c1926bf336a518ef6dd840ac5725 /src/normal.cc
parent6bb775241cf44fa2aec40c1fa0294e8b7379cf70 (diff)
Store the last used buffer in clients
Fixes #474
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 28347413..a7e0a515 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -160,14 +160,15 @@ void goto_commands(Context& context, NormalParams params)
break;
case 'a':
{
- auto& buffer_manager = BufferManager::instance();
- auto it = buffer_manager.begin();
- if (it->get() == &buffer and ++it == buffer_manager.end())
+ Buffer* target = nullptr;
+ if (not context.has_client() or
+ not (target = context.client().last_buffer()))
+ {
+ context.print_status({"no last buffer", get_face("Error")});
break;
- Buffer& target = **it;
- BufferManager::instance().set_last_used_buffer(buffer);
+ }
context.push_jump();
- context.change_buffer(target);
+ context.change_buffer(*target);
break;
}
case 'f':
@@ -195,8 +196,6 @@ void goto_commands(Context& context, NormalParams params)
if (buffer != &context.buffer())
{
- Buffer* oldbuf = &context.buffer();
- BufferManager::instance().set_last_used_buffer(*oldbuf);
context.push_jump();
context.change_buffer(*buffer);
}
@@ -1113,7 +1112,6 @@ void jump(Context& context, NormalParams)
Buffer* oldbuf = &context.buffer();
Buffer& buffer = const_cast<Buffer&>(jump.buffer());
- BufferManager::instance().set_last_used_buffer(buffer);
if (&buffer != oldbuf)
context.change_buffer(buffer);
context.selections_write_only() = jump;