Fix readonly behaviour

Make readonly specified on startup only apply to files provided on
the command line, and use the correct scope in `edit -readonly`

Fixes #4278
This commit is contained in:
Maxime Coste 2021-08-22 22:59:16 +10:00
parent c1e8f57bd6
commit e454b393cf
2 changed files with 4 additions and 3 deletions

View File

@ -395,7 +395,7 @@ void edit(const ParametersParser& parser, Context& context, const ShellContext&)
if (parser.get_switch("readonly")) if (parser.get_switch("readonly"))
{ {
buffer->flags() |= Buffer::Flags::ReadOnly; buffer->flags() |= Buffer::Flags::ReadOnly;
buffer->options()["readonly"].set(true); buffer->options().get_local_option("readonly").set(true);
} }
} }

View File

@ -781,8 +781,6 @@ int run_server(StringView session, StringView server_init,
} }
#endif #endif
GlobalScope::instance().options().get_local_option("readonly").set<bool>(flags & ServerFlags::ReadOnly);
bool startup_error = false; bool startup_error = false;
if (not (flags & ServerFlags::IgnoreKakrc)) try if (not (flags & ServerFlags::IgnoreKakrc)) try
{ {
@ -824,7 +822,10 @@ int run_server(StringView session, StringView server_init,
{ {
Buffer *buffer = open_or_create_file_buffer(file); Buffer *buffer = open_or_create_file_buffer(file);
if (flags & ServerFlags::ReadOnly) if (flags & ServerFlags::ReadOnly)
{
buffer->flags() |= Buffer::Flags::ReadOnly; buffer->flags() |= Buffer::Flags::ReadOnly;
buffer->options().get_local_option("readonly").set(true);
}
} }
catch (runtime_error& error) catch (runtime_error& error)
{ {