jarun/nnn

Current selection does not change to newly created dir, if current working directory path contains a symlink

7ocb opened this issue · 2 comments

7ocb commented

Environment details (Put x in the checkbox along with the information)

  • Operating System:

    ❯ uname -a
    Linux elkbook 6.5.9-arch2-1 #1 SMP PREEMPT_DYNAMIC Thu, 26 Oct 2023 00:52:20 +0000 x86_64 GNU/Linux
    
  • Desktop Environment: xmonad

  • Terminal Emulator: xterm

  • Shell:

    ❯ zsh --version
    zsh 5.9 (x86_64-pc-linux-gnu
    
  • Custom desktop opener (if applicable):

  • Program options used: none

  • Configuration options set: default

  • Plugins are installed: None

  • Issue exists on nnn master

Exact steps to reproduce the issue

Preparation:

Test directory structure:

test-structure/dir
test-structure/outer
test-structure/outer/dir # symlink to "test-structure/dir"

script to spawn:

#!/bin/sh

mkdir test-structure
mkdir test-structure/{dir,outer}
ln -s ../dir test-structure/outer

Reproducing:

  1. Start nnn
  2. Cd to test-structure/dir
  3. Create directories aaa and ccc - note each time directory is created, nnn shifts selection so cursor points to newly created entry - this working as expected.
  4. Cd to test-structure/outer/dir
  5. Create directory bbb - note that selection is not changed and cursor stays on same entry, new entry appears after some delay. Expected: as in 3: newly created item expected to be selected after creation.

Debugging notes:

It seems to me that the problem is that in tmp = get_cwd_entry(path, tmp, &len); ( file nnn.c line 7857 ), in get_cwd_entry in this case cwdpath will contain "symlinked" path (i.e. path via symlink) while entrypath will contain absolute (real) path to the entry being created. Because of this in this case entrypath is not considered as subpath of cwdpath.

Please raise a PR.