Bug: `plenary.filetype` module overwrites `fs_access = false` option with default value

Open
#652 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
lua, neovim
Domain
tooling

Research direction

Open lua/plenary/filetype.lua and inspect the option handling around line 161. Verify that an explicitly supplied fs_access = false remains false while an unspecified option receives the default true; the issue is done when both cases behave as expected.

Written by the indexing model from the issue text.

Description

Issue

There's a bug in lua/plenary/filetype.lua where if you explicitly pass fs_access = false as an option, it gets overwritten with the default value true. This causes text matches to be converted to "" when the filepath exists.

Current behavior

In the code at line 161:

opts.fs_access = opts.fs_access or true

This expression will always set opts.fs_access to true if its current value is false.

Expected behavior

The code should only set the default value if opts.fs_access is nil (unspecified), not when it's explicitly set to false.

Proposed fix

Change line 161 to:

opts.fs_access = (opts.fs_access == nil and true) or opts.fs_access

fs_access only gets the default value of true when it hasn't been specified, preserving any explicitly set value including false.

Dominant language
Lua
Stars
3.5k
Forks
340
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nvim-lua/plenary.nvim

All issues in nvim-lua/plenary.nvim

Similar issues

More Lua issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.