[readline] skip adding append character to suggestion

pull/1265/head v0.12.2-beta2
Tim Stack 1 month ago
parent ab606ca1b3
commit 1e348993f9

@ -481,7 +481,7 @@ com_set_file_timezone_prompt(exec_context& ec, const std::string& cmdline)
return {new_prompt}; return {new_prompt};
} }
return {"", file_zone}; return {"", file_zone + " "};
} catch (const std::runtime_error& e) { } catch (const std::runtime_error& e) {
log_error("cannot get timezones: %s", e.what()); log_error("cannot get timezones: %s", e.what());
} }

@ -200,7 +200,7 @@ private:
std::map<std::string, std::vector<std::string>> rc_prototypes; std::map<std::string, std::vector<std::string>> rc_prototypes;
std::map<std::string, command_t*> rc_commands; std::map<std::string, command_t*> rc_commands;
bool rc_case_sensitive; bool rc_case_sensitive;
int rc_append_character; int rc_append_character{' '};
const char* rc_quote_chars; const char* rc_quote_chars;
readline_highlighter_t rc_highlighter; readline_highlighter_t rc_highlighter;
std::vector<readline_var> rc_vars; std::vector<readline_var> rc_vars;

@ -414,6 +414,7 @@ readline_context::attempted_completion(const char* text, int start, int end)
suggestion_possibilities.clear(); suggestion_possibilities.clear();
suggestion_possibilities.emplace(rc_local_suggestion); suggestion_possibilities.emplace(rc_local_suggestion);
arg_possibilities = &suggestion_possibilities; arg_possibilities = &suggestion_possibilities;
rl_completion_append_character = 0;
} else if (at_start } else if (at_start
&& loaded_context->rc_possibilities.find(cmd_key) && loaded_context->rc_possibilities.find(cmd_key)
!= loaded_context->rc_possibilities.end()) != loaded_context->rc_possibilities.end())
@ -680,8 +681,6 @@ readline_context::readline_context(std::string name,
auto hpath = (config_dir / this->rc_name).string() + ".history"; auto hpath = (config_dir / this->rc_name).string() + ".history";
read_history(hpath.c_str()); read_history(hpath.c_str());
this->save(); this->save();
this->rc_append_character = ' ';
} }
void void
@ -974,7 +973,6 @@ readline_curses::start()
} else { } else {
uint64_t h1 = 1, h2 = 2; uint64_t h1 = 1, h2 = 2;
rc_local_suggestion.clear();
if (rl_last_func == readline_context::command_complete) { if (rl_last_func == readline_context::command_complete) {
rl_last_func = rl_menu_complete; rl_last_func = rl_menu_complete;
} }
@ -1014,14 +1012,17 @@ readline_curses::start()
if (h1 == last_h1 && h2 == last_h2) { if (h1 == last_h1 && h2 == last_h2) {
// do nothing // do nothing
} else if (sendcmd(this->rc_command_pipe[RCF_SLAVE], } else {
complete_done ? 'l' : 'c', rc_local_suggestion.clear();
rl_line_buffer, if (sendcmd(this->rc_command_pipe[RCF_SLAVE],
rl_end) complete_done ? 'l' : 'c',
!= 0) rl_line_buffer,
{ rl_end)
perror("line: write failed"); != 0)
_exit(1); {
perror("line: write failed");
_exit(1);
}
} }
last_h1 = h1; last_h1 = h1;
last_h2 = h2; last_h2 = h2;
@ -1057,10 +1058,14 @@ readline_curses::start()
if (rl_prompt) { if (rl_prompt) {
new_point -= strlen(rl_prompt); new_point -= strlen(rl_prompt);
} }
if (0 <= new_point && new_point <= rl_end) { if (new_point < 0) {
rl_point = new_point; new_point = 0;
rl_redisplay();
} }
if (new_point > rl_end) {
new_point = rl_end;
}
rl_point = new_point;
rl_redisplay();
} else if (sscanf(msg, "i:%d:%n", &rl_point, &prompt_start) } else if (sscanf(msg, "i:%d:%n", &rl_point, &prompt_start)
== 1) == 1)
{ {

@ -262,7 +262,7 @@ prql_cmd_from_prompt(exec_context& ec, const std::string& cmdline)
= line_pair->first->get_format_ptr()->get_name().to_string(); = line_pair->first->get_format_ptr()->get_name().to_string();
return { return {
"", "",
lnav::prql::quote_ident(format_name), lnav::prql::quote_ident(format_name) + " ",
}; };
} }

Loading…
Cancel
Save