Skip to content

Commit f430f44

Browse files
committed
[history] fix history for mouse input
1 parent e7de7b9 commit f430f44

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/command_executor.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,8 +1275,10 @@ exec_context::execute(source_location loc, const std::string& cmdline)
12751275
auto sg = this->enter_source(loc, cmdline);
12761276

12771277
auto before_dls_gen = dls.dls_generation;
1278-
if (this->get_provenance<mouse_input>() && !prompt.p_editor.is_enabled()) {
1279-
auto& hist = prompt.get_history_for();
1278+
if (this->get_provenance<mouse_input>() && !prompt.p_editor.is_enabled()
1279+
&& !cmdline.empty())
1280+
{
1281+
auto& hist = prompt.get_history_for(cmdline[0]);
12801282
hist_guard = hist.start_operation(cmdline.substr(1));
12811283
}
12821284

src/lnav.prompt.hh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ struct prompt {
126126
}
127127
}
128128

129+
lnav::textinput::history& get_history_for(char ch)
130+
{
131+
switch (ch) {
132+
case ';':
133+
return this->p_sql_history;
134+
case ':':
135+
return this->p_cmd_history;
136+
case '/':
137+
return this->p_search_history;
138+
case '|':
139+
return this->p_script_history;
140+
default:
141+
ensure(false);
142+
}
143+
}
144+
129145
context_t p_current_context{context_t::none};
130146
std::map<std::string, std::string> p_env_vars;
131147
std::multimap<std::string, sql_item_t, strnatcaseless> p_sql_completions;

0 commit comments

Comments
 (0)