Try fix prompt_start_row reset to 0 when opening a file without newline in Nushell (#697)

* adjust is_reset

* add a word

* Revert "add a word"

This reverts commit e61be57724.
This commit is contained in:
WindSoilder 2024-01-06 06:37:52 +08:00 committed by GitHub
parent aa101f4d69
commit b68ce33c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -153,7 +153,10 @@ impl Painter {
// This might not be terribly performant. Testing it out
let is_reset = || match cursor::position() {
Ok(position) => position.1.abs_diff(self.prompt_start_row) > 1,
// when output something without newline, the cursor position is at current line.
// but the prompt_start_row is next line.
// in this case we don't want to reset, need to `add 1` to handle for such case.
Ok(position) => position.1 + 1 < self.prompt_start_row,
Err(_) => false,
};