Skip to content

Commit

Permalink
improve the size of completions page to show the entire prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
s417-lama authored and ridiculousfish committed Feb 4, 2018
1 parent 9ba6b62 commit 27c1c06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,11 @@ static void reader_repaint() {
std::vector<int> indents = data->indents;
indents.resize(len);

// Re-render our completions page if necessary. We set the term size to 1 less than the true
// term height. This means we will always show the (bottom) line of the prompt.
data->pager.set_term_size(maxi(1, common_get_width()), maxi(1, common_get_height() - 1));
// Re-render our completions page if necessary. We set the term size to less than the true
// term height by the number of prompt lines. This means we will always show the entire line of
// the prompt.
data->pager.set_term_size(maxi(1, common_get_width()),
maxi(1, common_get_height() - (int)calc_prompt_lines(full_line)));
data->pager.update_rendering(&data->current_page_rendering);

bool focused_on_pager = data->active_edit_line() == &data->pager.search_field_line;
Expand Down
2 changes: 1 addition & 1 deletion src/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ static prompt_layout_t calc_prompt_layout(const wchar_t *prompt, prompt_type_t w
return prompt_layout;
}

static size_t calc_prompt_lines(const wcstring &prompt) {
size_t calc_prompt_lines(const wcstring &prompt) {
// Hack for the common case where there's no newline at all. I don't know if a newline can
// appear in an escape sequence, so if we detect a newline we have to defer to
// calc_prompt_width_and_lines.
Expand Down
3 changes: 3 additions & 0 deletions src/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,7 @@ class cached_esc_sequences_t {
// change by calling `cached_esc_sequences.clear()`.
extern cached_esc_sequences_t cached_esc_sequences;

// Calculates the number of prompt lines.
size_t calc_prompt_lines(const wcstring &prompt);

#endif

0 comments on commit 27c1c06

Please sign in to comment.