echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.54k stars 175 forks source link

mini.files: error when opening explorer with path which does not exist on disk #840

Closed nat-418 closed 2 months ago

nat-418 commented 2 months ago

Contributing guidelines

Module(s)

mini.files

Description

If I open a new file and then try to navigate its parent directory using -, I get an E5108: Error executing lua: (mini.files)pathis not a valid path error. I don't think the file not being written should matter, since the parent directory exists.

Neovim version

v0.10.0-dev-c81b784

Steps to reproduce

  1. mkdir -p foo
  2. echo "a" > foo/a.txt
  3. nvim foo/b.txt
  4. press -

Expected behavior

show me my directory explorer

Actual behavior

error

echasnovski commented 2 months ago

This is intended and documented behavior. Ensuring that path actually exists on disk simplifies code logic down the line by removing the need to do later checks.

Plus I assume that - calls MiniFiles.open() with the path of the current file, which should result with cursor placed on that file in the explorer. This is impossible because there is no file on disk (yet).

The cost of not being able to open explorer with focus on non-existing path seems OK for me.

Closing as not planned.