Add test for fix of issue #7754#7756
Conversation
|
please add more info in the description. "This PR fixes issue #7754 which blah blah blah. Here are how it works before: and after:" |
|
@fdncred sorry about that I though the information in the issue was enough. I updated it :) |
|
No worries. It's better for us to have a proper title and description on each PR in case we have to revert one. Thanks. |
|
Would you mind adding a test that reproduces the previous panic? |
I tried to do that but the code actually does the suggestion instead of crashing.... I tested in the main branch with this: // crates\nu-cli\tests\completions.rs
#[rstest]
fn alias_offset_bug_7754() {
let (dir, _, mut engine, mut stack) = new_engine();
// Create an alias
let alias = r#"alias ll = ls -l"#;
assert!(support::merge_input(alias.as_bytes(), &mut engine, &mut stack, dir.clone()).is_ok());
let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack);
let suggestions = completer.complete("ll -a | c", 9);
println!(" --------- suggestions: {:?}", suggestions);
}and instead of crashing it actually gets the suggestions... Am I doing something wrong? |
|
@sholderbach never mind. It does crash on the main branch. Test added! |
|
Great! Is the corresponding fix already landed through #7779? |
|
@sholderbach We still need to merge this PR. The bug is similar to the one fixed on #7779 (issue related to the offset) but this code patches different areas |
|
OK maybe something went wrong in the merge process because Github only shows the added tests in the final diff. |
|
@sholderbach Actually you are right. Yes! sorry for the confusion. I was working on one bug and then someone else pointed out another one and I branched out from that one. So, yes, the fix was already landed through #7779 but it is missing the test that it is still here |
|
Great! Thanks for the test as well. |
Fix already landed with nushell#7779
Description
Fixes issue #7754 which used to crash on when name of the alias was shorter than the command and if the command contains any pipes. check bellow for an example:
before
add the next to your
$nu.config-pathNow press
tabright after thecAfter
With the patch on this PR the shell no longer crashes on that situation.
User-Facing Changes
None
Tests + Formatting
Checking how to add test to this particular case.... Is it actually possible?
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspaceto check that all tests pass