Make edit
command work fine when running from an empty context
This way, the kind of context we get from a piped command allows for opening a buffer and working with it directly.
This commit is contained in:
parent
ce2c0e54f4
commit
4b06c09c68
|
@ -249,11 +249,13 @@ void edit(const ParametersParser& parser, Context& context, const ShellContext&)
|
|||
buffer->flags() &= ~Buffer::Flags::NoHooks;
|
||||
}
|
||||
|
||||
Buffer* current_buffer = context.has_buffer() ? &context.buffer() : nullptr;
|
||||
|
||||
const size_t param_count = parser.positional_count();
|
||||
if (buffer != &context.buffer() or param_count > 1)
|
||||
if (current_buffer and (buffer != current_buffer or param_count > 1))
|
||||
context.push_jump();
|
||||
|
||||
if (buffer != &context.buffer())
|
||||
if (buffer != current_buffer)
|
||||
context.change_buffer(*buffer);
|
||||
|
||||
if (param_count > 1 and not parser[1].empty())
|
||||
|
|
|
@ -159,10 +159,10 @@ void JumpList::forget_buffer(Buffer& buffer)
|
|||
|
||||
void Context::change_buffer(Buffer& buffer)
|
||||
{
|
||||
if (&buffer == &this->buffer())
|
||||
if (has_buffer() and &buffer == &this->buffer())
|
||||
return;
|
||||
|
||||
if (m_edition_level > 0)
|
||||
if (has_buffer() and m_edition_level > 0)
|
||||
this->buffer().commit_undo_group();
|
||||
|
||||
m_window.reset();
|
||||
|
|
Loading…
Reference in New Issue
Block a user