aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-04-29 12:14:10 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-04-29 12:33:06 -0700
commit8e19c82e09671a11aad0265e4352bce4d73cf420 (patch)
tree605440638468e3f6be2283b79d66354d595c67a3 /src
parent09bb71398938ffdc4b46767de7bf8cc18ac3cda1 (diff)
Issue a \r in fish_title, except when executing it for the prompt
fish_title currently outputs some escaped text, which can confuse the line driver (#2453). Issue a carriage return so the line driver knows we are at the beginning of the line, unless we are writing the title as part of the prompt. In that case, we may have text from the previous command still on the line and we don't want to move the cursor. Fixes #2453
Diffstat (limited to 'src')
-rw-r--r--src/reader.cpp12
-rw-r--r--src/reader.h3
2 files changed, 11 insertions, 4 deletions
diff --git a/src/reader.cpp b/src/reader.cpp
index 50c8c93d..18f2a731 100644
--- a/src/reader.cpp
+++ b/src/reader.cpp
@@ -873,7 +873,7 @@ bool reader_thread_job_is_stale()
return (void*)(uintptr_t) s_generation_count != pthread_getspecific(generation_count_key);
}
-void reader_write_title(const wcstring &cmd)
+void reader_write_title(const wcstring &cmd, bool reset_cursor_position)
{
const env_var_t term_str = env_get_string(L"TERM");
@@ -944,6 +944,10 @@ void reader_write_title(const wcstring &cmd)
}
proc_pop_interactive();
set_color(rgb_color_t::reset(), rgb_color_t::reset());
+ if (reset_cursor_position && ! lst.empty()) {
+ // Put the cursor back at the beginning of the line #2453
+ writestr(L"\r");
+ }
}
/**
@@ -1002,8 +1006,10 @@ static void exec_prompt()
proc_pop_interactive();
}
- /* Write the screen title */
- reader_write_title(L"");
+ // Write the screen title.
+ // Do not reset the cursor position: exec_prompt is called when there may still be output
+ // on the line from the previous command (#2499) and we need our PROMPT_SP hack to work
+ reader_write_title(L"", false);
}
void reader_init()
diff --git a/src/reader.h b/src/reader.h
index 3d9208a0..67ba1a2e 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -117,8 +117,9 @@ void reader_pop_current_filename();
finishes.
\param cmd Command line string passed to \c fish_title if is defined.
+ \param reset_cursor_position If set, issue a \r so the line driver knows where we are
*/
-void reader_write_title(const wcstring &cmd);
+void reader_write_title(const wcstring &cmd, bool reset_cursor_position = true);
/**
Call this function to tell the reader that a repaint is needed, and