Remove ellipsis and newlines from long lines

Fix for issue https://github.com/fish-shell/fish-shell/issues/300
This commit is contained in:
Siteshwar Vashisht
2012-09-18 00:42:11 +05:30
parent 86a978d9ee
commit 16f2ffc29d
7 changed files with 6 additions and 91 deletions

View File

@@ -445,29 +445,22 @@ static void s_desired_append_char( screen_t *s,
{
int screen_width = common_get_width();
int cw = fish_wcwidth(b);
int ew = fish_wcwidth( ellipsis_char );
s->desired.create_line(line_no);
/*
Check if we are at the end of the line. If so, print an
ellipsis character and continue on the next line.
Check if we are at the end of the line. If so, continue on the next line.
*/
if( s->desired.cursor.x + cw + ew > screen_width )
if( (s->desired.cursor.x + cw) > screen_width )
{
s->desired.line(line_no).append(ellipsis_char, HIGHLIGHT_COMMENT);
line_no = (int)s->desired.line_count();
s->desired.add_line();
s->desired.cursor.y++;
s->desired.cursor.x=0;
if (prompt_width > ew) {
for( size_t i=0; i < (prompt_width-ew); i++ )
{
s_desired_append_char( s, L' ', 0, indent, prompt_width );
}
for( size_t i=0; i < prompt_width; i++ )
{
s_desired_append_char( s, L' ', 0, indent, prompt_width );
}
s_desired_append_char( s, ellipsis_char, HIGHLIGHT_COMMENT, indent, prompt_width );
}
line_t &line = s->desired.line(line_no);
@@ -871,7 +864,6 @@ void s_write( screen_t *s,
assert(screen_width - prompt_width >= 1);
max_line_width = screen_width - prompt_width - 1;
truncated_autosuggestion_line = wcstring(commandline, 0, last_char_that_fits);
truncated_autosuggestion_line.push_back(ellipsis_char);
commandline = truncated_autosuggestion_line.c_str();
}
for( size_t i=0; i<prompt_width; i++ )
@@ -906,17 +898,6 @@ void s_write( screen_t *s,
s_desired_append_char( s, commandline[i], col, indent[i], prompt_width );
if( i== cursor_pos && s->desired.cursor.y != cursor_arr.y && commandline[i] != L'\n' )
{
/*
Ugh. We are placed exactly at the wrapping point of a
wrapped line, move cursor to the line below so the
cursor won't be on the ellipsis which looks
unintuitive.
*/
cursor_arr.x = s->desired.cursor.x - fish_wcwidth(commandline[i]);
cursor_arr.y = s->desired.cursor.y;
}
}
if( i == cursor_pos )
{