mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 22:17:52 +08:00
Do not emit newline when running commands if the cursor is on its own line
If the cursor has been wrapped to the last line, and is the only thing on that line, do not emit a newline when executing a command. Fixes #6826
This commit is contained in:
parent
81af389258
commit
4f103d74fb
|
@ -3581,7 +3581,11 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
|
||||||
repaint_if_needed();
|
repaint_if_needed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emit a newline so that the output is on the line after the command.
|
||||||
|
// But do not emit a newline if the cursor has wrapped onto a new line all its own - see #6826.
|
||||||
|
if (!screen.cursor_is_wrapped_to_own_line()) {
|
||||||
ignore_result(write(STDOUT_FILENO, "\n", 1));
|
ignore_result(write(STDOUT_FILENO, "\n", 1));
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure we have no pager contents when we exit.
|
// Ensure we have no pager contents when we exit.
|
||||||
if (!pager.empty()) {
|
if (!pager.empty()) {
|
||||||
|
|
|
@ -1222,3 +1222,10 @@ void screen_force_clear_to_end() {
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_t::screen_t() : outp_(outputter_t::stdoutput()) {}
|
screen_t::screen_t() : outp_(outputter_t::stdoutput()) {}
|
||||||
|
|
||||||
|
bool screen_t::cursor_is_wrapped_to_own_line() const {
|
||||||
|
// Note == comparison against the line count is correct: we do not create a line just for the
|
||||||
|
// cursor. If there is a line containing the cursor, then it means that line has contents and we
|
||||||
|
// should return false.
|
||||||
|
return actual.cursor.x == 0 && static_cast<size_t>(actual.cursor.y) == actual.line_count();
|
||||||
|
}
|
||||||
|
|
|
@ -154,6 +154,10 @@ class screen_t {
|
||||||
|
|
||||||
/// \return the outputter for this screen.
|
/// \return the outputter for this screen.
|
||||||
outputter_t &outp() { return outp_; }
|
outputter_t &outp() { return outp_; }
|
||||||
|
|
||||||
|
/// \return whether we believe the cursor is wrapped onto the last line, and that line is
|
||||||
|
/// otherwise empty. This includes both soft and hard wrapping.
|
||||||
|
bool cursor_is_wrapped_to_own_line() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This is the main function for the screen putput library. It is used to define the desired
|
/// This is the main function for the screen putput library. It is used to define the desired
|
||||||
|
|
Loading…
Reference in New Issue
Block a user