Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prompt_start_row reset to 0 when opening a file without newline in Nushell #688

Merged
merged 1 commit into from
Dec 23, 2023

Conversation

nibon7
Copy link
Contributor

@nibon7 nibon7 commented Dec 23, 2023

Copy link

codecov bot commented Dec 23, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (0046da9) 49.17% compared to head (ae68d9b) 49.26%.
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #688      +/-   ##
==========================================
+ Coverage   49.17%   49.26%   +0.08%     
==========================================
  Files          46       46              
  Lines        7924     7911      -13     
==========================================
  Hits         3897     3897              
+ Misses       4027     4014      -13     
Files Coverage Δ
src/painting/prompt_lines.rs 0.00% <0.00%> (ø)
src/painting/painter.rs 19.34% <0.00%> (+0.71%) ⬆️

@amtoine
Copy link
Member

amtoine commented Dec 23, 2023

@nibon7
is it possible to test this patch with one of the Reedline examples?

@nibon7
Copy link
Contributor Author

nibon7 commented Dec 23, 2023

It could be reproduced by applying the patch below 😅 , just print something without newline.

When we print something without newline, then the column > 0 is true, self.prompt_start_raw = postition.1 + 1.

let new_row = if column > 0 { row + 1 } else { row };

diff --git a/examples/demo.rs b/examples/demo.rs
index 2e7a402..00d3dae 100644
--- a/examples/demo.rs
+++ b/examples/demo.rs
@@ -201,6 +201,7 @@ fn main() -> std::io::Result<()> {
                     continue;
                 }
                 println!("Our buffer: {buffer}");
+                print!(" ");
                 #[cfg(any(feature = "sqlite", feature = "sqlite-dynlib"))]
                 if !buffer.is_empty() {
                     line_editor

@sholderbach
Copy link
Member

That change makes sense and fixes your provided repro. Thanks @nibon7

@sholderbach sholderbach merged commit e097b88 into nushell:main Dec 23, 2023
8 checks passed
sholderbach added a commit to sholderbach/nushell that referenced this pull request Dec 23, 2023
@nibon7 nibon7 deleted the prompt_start_row branch December 23, 2023 17:42
sholderbach added a commit to nushell/nushell that referenced this pull request Dec 23, 2023
@fdncred
Copy link
Collaborator

fdncred commented Dec 26, 2023

I think this PR is breaking things. I put some notes about it here nushell/nushell#11406 (comment). There's a gif on discord in that link.

@amtoine
Copy link
Member

amtoine commented Dec 26, 2023

I think this PR is breaking things. I put some notes about it here nushell/nushell#11406 (comment). There's a gif on discord in that link.

i suspect #675 is the real responsible for these bugs 🤔

fdncred added a commit to nushell/nushell that referenced this pull request Dec 26, 2023
Reverts #11406

This PR nushell/reedline#688 is causing clear
screens to happen at strange times. Documented here
#11406 (comment)
@fdncred
Copy link
Collaborator

fdncred commented Dec 26, 2023

We probably need to revert this one too.

@sholderbach
Copy link
Member

sholderbach commented Dec 26, 2023

@danielsomerfield @nibon7 sounds like we need to figure out a way to make the new prompt position logic from #675 to work without causing either nushell/nushell#11406 (comment) or nushell/nushell#11399

Maybe we need to rethink how initialize_prompt_position interacts with the new cursor position polling (for solving nushell/nushell#11339) to invalidate.

dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
Reverts nushell#11406

This PR nushell/reedline#688 is causing clear
screens to happen at strange times. Documented here
nushell#11406 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nushell reset prompt_start_row to 0 when opening a file without newline
4 participants