Skip to content

Commit

Permalink
Try fix prompt_start_row reset to 0 when opening a file without newli…
Browse files Browse the repository at this point in the history
…ne in Nushell (#697)

* adjust is_reset

* add a word

* Revert "add a word"

This reverts commit e61be57.
  • Loading branch information
WindSoilder authored Jan 5, 2024
1 parent aa101f4 commit b68ce33
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/painting/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down

0 comments on commit b68ce33

Please sign in to comment.