nushell: Broken completion with alias

Describe the bug

Hi, first of all, thank you for the awesome shell and shell programming language!

some days ago, trying to use nushell git version, doesn’t allow me to autocomplete ?some? alias. (I haven’t done an extensive check to say that its all alias)

Example, I have cat aliased to: bat --style header --style rules --style snip --style changes --style header --pager=never

In previous nushell (the stable release) I can do for example cat /tm and tab my way to autocompletion.

In git version, it just says right away “NO RECORDS FOUND”.

Also, if I do /usr/bin/cat /tm I can again autocomplete.

From my quick findings, functions seem to be working (autocompleting), but not alias.

Also, don’t know if it can be in the same bug or not, but seems related:

Doing an alias of an alias seems to crash nushell:

│ 0 │ ll  │ Nushell alias: _ls -l --sort=time │ false    │
│ 0 │ _ls │ Nushell alias: exa --color=always --group-directories-first --icons │ false    │

So … ll is an alias for _ls which is an alias for the command exa.

Running ll space, then “/” and then tab, results in:

 | ll thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', crates/nu-cli/src/completions/completer.rs:76:25
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <nu_cli::completions::completer::NuCompleter as reedline::completion::base::Completer>::complete
   4: <reedline::menu::columnar_menu::ColumnarMenu as reedline::menu::Menu>::update_values
   5: reedline::engine::Reedline::handle_editor_event
   6: reedline::engine::Reedline::read_line
   7: nu_cli::repl::evaluate_repl
   8: nu::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

If you need full backtrace, or if the issue is badly done, just give me a notice and I will try to give more info!

How to reproduce

  1. create an alias
  2. use alias and try to autocomplete with tab

Expected behavior

I expected nu to autocomplete files or folders, but just says right away “NO RECORDS FOUND”

It does work properly in the stable version (0.63), only git version is affected.

Screenshots

No response

Configuration

No response

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 25 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@Kangaxx-0

I just tested that pull request/branch … and … quick testing, but seems good! ll works and cat works ( alias and alias of alias ) !

Thanks very much !!! ( i will keep testing, if anything appears, i will post here )

I really appreciated your test, I added a few new unit tests and about to publish my fix. Thank you!

good catch @alexjp! @Kangaxx-0 could you please add a new test for this command so we can keep track of it? Once the current tests couldn’t catch this case.