summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-11-07 14:04:47 +0100
committerMaxime Coste <frrrwww@gmail.com>2012-11-07 14:04:47 +0100
commitbdd0758ee2993e4a3be34027a2f23e75d984fd9b (patch)
treef0729631f1d659c071c9f92f587909ef64987afd /src
parent0f7948848e662f1bb3f299b7a8c3e7d335adae1f (diff)
Saner :edit and :buffer behaviour when buffer is the current one
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 98b14123..55fcf2ff 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -282,7 +282,12 @@ void edit(const CommandParameters& params, Context& context)
}
BufferManager::instance().set_last_used_buffer(*buffer);
- Window& window = ClientManager::instance().get_unused_window_for_buffer(*buffer);
+
+ if (buffer != &context.buffer())
+ {
+ auto& manager = ClientManager::instance();
+ context.change_editor(manager.get_unused_window_for_buffer(*buffer));
+ }
if (param_count > 1)
{
@@ -290,11 +295,10 @@ void edit(const CommandParameters& params, Context& context)
int column = param_count > 2 ?
std::max(0, str_to_int(parser[2]) - 1) : 0;
- window.select(window.buffer().iterator_at({ line, column }));
- window.center_selection();
+ context.editor().select(context.buffer().iterator_at({ line, column }));
+ if (context.has_window())
+ context.window().center_selection();
}
-
- context.change_editor(window);
}
void write_buffer(const CommandParameters& params, Context& context)
@@ -378,8 +382,12 @@ void show_buffer(const CommandParameters& params, Context& context)
throw runtime_error("buffer " + buffer_name + " does not exists");
BufferManager::instance().set_last_used_buffer(*buffer);
- Window& window = ClientManager::instance().get_unused_window_for_buffer(*buffer);
- context.change_editor(window);
+
+ if (buffer != &context.buffer())
+ {
+ auto& manager = ClientManager::instance();
+ context.change_editor(manager.get_unused_window_for_buffer(*buffer));
+ }
}
void delete_buffer(const CommandParameters& params, Context& context)