From e454b393cfaa69d270dda842b40d9c8fc3d672e6 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 22 Aug 2021 22:59:16 +1000 Subject: [PATCH] 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 --- src/commands.cc | 2 +- src/main.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index d71ff183..543b14a5 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -395,7 +395,7 @@ void edit(const ParametersParser& parser, Context& context, const ShellContext&) if (parser.get_switch("readonly")) { buffer->flags() |= Buffer::Flags::ReadOnly; - buffer->options()["readonly"].set(true); + buffer->options().get_local_option("readonly").set(true); } } diff --git a/src/main.cc b/src/main.cc index fb0b165b..f3a4aef9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -781,8 +781,6 @@ int run_server(StringView session, StringView server_init, } #endif - GlobalScope::instance().options().get_local_option("readonly").set(flags & ServerFlags::ReadOnly); - bool startup_error = false; 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); if (flags & ServerFlags::ReadOnly) + { buffer->flags() |= Buffer::Flags::ReadOnly; + buffer->options().get_local_option("readonly").set(true); + } } catch (runtime_error& error) {