Change mode_info to contain an optional NormalParams
As @topisani pointed out in #5131, it is more user friendly to always provide a %val{register} and %val{count} regardless of the mode.
This commit is contained in:
parent
cc935c8cc6
commit
917db454d9
|
@ -165,12 +165,16 @@ DisplayLine Client::generate_mode_line() const
|
|||
DisplayLine modeline;
|
||||
try
|
||||
{
|
||||
ModeInfo mode_info = context().client().input_handler().mode_info();
|
||||
auto [mode_info_line, normal_params] = context().client().input_handler().mode_info();
|
||||
const String& modelinefmt = context().options()["modelinefmt"].get<String>();
|
||||
HashMap<String, DisplayLine> atoms{{ "mode_info", mode_info.display_line},
|
||||
HashMap<String, DisplayLine> atoms{{ "mode_info", mode_info_line},
|
||||
{ "context_info", {generate_context_info(context()),
|
||||
context().faces()["Information"]}}};
|
||||
auto expanded = expand(modelinefmt, context(), {{}, mode_info.env_vars},
|
||||
ShellContext shell_context{{}, {
|
||||
{"register", normal_params ? StringView{normal_params->reg}.str() : ""},
|
||||
{"count", normal_params ? String{to_string(normal_params->count)} : ""},
|
||||
}};
|
||||
auto expanded = expand(modelinefmt, context(), shell_context,
|
||||
[](String s) { return escape(s, '{', '\\'); });
|
||||
modeline = parse_display_line(expanded, context().faces(), atoms);
|
||||
}
|
||||
|
|
|
@ -390,7 +390,7 @@ public:
|
|||
atoms.emplace_back(" reg=", context().faces()["StatusLineInfo"]);
|
||||
atoms.emplace_back(StringView(m_params.reg).str(), context().faces()["StatusLineValue"]);
|
||||
}
|
||||
return {atoms, {{"count", to_string(m_params.count)}, {"register", StringView(m_params.reg).str()}}};
|
||||
return {atoms, m_params};
|
||||
}
|
||||
|
||||
KeymapMode keymap_mode() const override { return KeymapMode::Normal; }
|
||||
|
|
|
@ -56,7 +56,7 @@ enum class InsertMode : unsigned
|
|||
struct ModeInfo
|
||||
{
|
||||
DisplayLine display_line;
|
||||
EnvVarMap env_vars;
|
||||
std::optional<NormalParams> normal_params;
|
||||
};
|
||||
|
||||
class InputHandler : public SafeCountable
|
||||
|
|
Loading…
Reference in New Issue
Block a user