diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-05-12 23:25:15 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-05-13 20:09:06 +0100 |
| commit | ea3e92aa5e68e73fa95196332b739891bbf3f24f (patch) | |
| tree | 1b91673cdbec34a9dcb592858890fc6db1255ff9 /src/commands.cc | |
| parent | 7bc73b7ef9402f81a6bb496b03ba84197f76e642 (diff) | |
SelectionList know its buffer and timestamp
Diffstat (limited to 'src/commands.cc')
| -rw-r--r-- | src/commands.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/commands.cc b/src/commands.cc index e3437dfa..4629c3d1 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -131,7 +131,8 @@ void edit(const ParametersParser& parser, Context& context) int column = param_count > 2 and not parser[2].empty() ? std::max(0, str_to_int(parser[2]) - 1) : 0; - context.selections() = context.buffer().clamp({ line, column }); + auto& buffer = context.buffer(); + context.selections() = { buffer, buffer.clamp({ line, column }) }; if (context.has_window()) context.window().center_line(context.selections().main().cursor().line); } @@ -962,7 +963,7 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) for (auto& name : names) { Buffer& buffer = BufferManager::instance().get_buffer(name); - InputHandler input_handler{buffer, ( Selection{} )}; + InputHandler input_handler{{ buffer, Selection{} }}; func(parser, input_handler.context()); } return; @@ -980,7 +981,7 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) if (parser.has_option("draft")) { - InputHandler input_handler(real_context->buffer(), real_context->selections(), real_context->name()); + InputHandler input_handler(real_context->selections(), real_context->name()); // We do not want this draft context to commit undo groups if the real one is // going to commit the whole thing later @@ -989,12 +990,17 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) if (parser.has_option("itersel")) { - DynamicSelectionList sels{real_context->buffer(), real_context->selections()}; + SelectionList sels{real_context->selections()}; ScopedEdition edition{input_handler.context()}; for (auto& sel : sels) { - input_handler.context().selections() = sel; + input_handler.context().selections() = SelectionList{ sels.buffer(), sel, sels.timestamp() }; + input_handler.context().selections().update(); + func(parser, input_handler.context()); + + if (&sels.buffer() != &input_handler.context().buffer()) + throw runtime_error("the buffer has changed while iterating on selections"); } } else |
