Files
qodelicious 131b82a921 fix(std/dirs): make dirs drop a no-op when only one directory is left (#19355)
## Description

`dirs drop` says it has no effect when there's only one directory in the
list. But it still called `_fetch -1 --forget_current --always_cd`,
which `cd`s to whatever is saved in that one slot. That slot isn't
updated when you plain `cd` somewhere, so it usually still holds the
directory nushell started in (or wherever the module was loaded). So `cd
/tmp; dirs drop` would jump you back to your home dir or the startup
dir.

Now `dirs drop` returns early when the list has one entry or less, so it
really does nothing, as the help says. Dropping with two or more entries
works like before.

Added `dirs_drop_single_entry` to `crates/nu-std/tests/test_dirs.nu`. It
fails on main (PWD goes back to the base dir) and passes with the fix.

## User-facing changes (Release notes)

Fixed `dirs drop` changing the working directory when the directory list
has only one entry. It now leaves you where you are.

## Additional notes

Fixes #12578
2026-10-27 06:31:28 -05:00
..