← Back to Pull requests

perf(#3383): retrieve executable status from existing fs_stat.mode rather than a subsequent call to fs_access, file links show correct executable status #3399

Merged
alex-courtis merged 5 files (54 lines) on Dec 03, 2026 22:58 UTC
View on GitHub
alex-courtis alex-courtis commented on Nov 30, 2026 01:31 UTC
Author

fixes #3383

@hood I'd be grateful for your review and testing on macos

I've opted to return true for any executable bit, not just user as it was previously. This can be considered a bug.

Diff: 54 lines (+45 / -9) across 5 files Reviewer: alex-courtis Review duration: 5607m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.47) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 54 lines diff across 5 files
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 5 substantive comment(s)
0.91
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.240
Self Review self_review
0.140
Real PR Conversation Timeline
9 items
alex-courtis alex-courtis commented on code on Nov 30, 2026 01:34 UTC
Code Review
lua/nvim-tree/utils.lua:1
@@ -437,15 +437,18 @@ function M.is_nvim_tree_buf(bufnr)
   return false
 end
 
---- path is an executable file or directory
----@param absolute_path string
+---File has any ugw executable bit set, excluding special
+---@param stat uv.fs_stat.result?
 ---@return boolean
-function M.is_executable(absolute_path)
+function M.is_executable(stat)
   if config.os.windows or config.os.wsl then
     --- executable detection on windows is buggy and not performant hence it is disabled
     return false
+  elseif stat then
+    -- mask executable only, no special ---x--x--x
+    return stat.mode & 73 > 0

lua doesn't have a nice way to use octal numbers

hood hood commented on Dec 02, 2026 09:19 UTC
Reviewer

thx for picking this up! tested on macOS (arm64), found 2 things:

1. & breaks on stable nvim

stat.mode & 73 only parses on nightly as the LuaJIT bundled with stable doesn't support the 5.3 bitwise ops yet. So utils.lua fails to load and the tree doesn't open at all:

NVIM v0.12.7 / v0.10.4:
utils.lua:449: 'end' expected (to close 'if' at line 444) near '&'

Side note: CI is 🟢 cause check / lint don't actually load the module.

I'd use bit.band(stat.mode, 73) ~= 0, which works on 0.10.4, 0.12.7 and nightly just fine.

2. every symlink is now executable

fs_stat is an lstat, and on macOS a symlink's own mode is 0777 so the mask always hits. I think that using the target stat is a decent fix:

-- node/file.lua
self.executable     = utils.is_executable(args.fs_stat_target or args.fs_stat)

-- explorer/init.lua reload
n.executable = utils.is_executable(n.fs_stat_target or stat)

Side note: fs_stat_target is from node creation so it can be a bit stale on reload if the target gets chmod'd, but that's kinda an edge case tbh 🤷‍♂️.

Some results: (fixture: plain 644, uexec 744, gexec 654, oexec 645, suid 4644, sticky 1644, link_exec -> uexec, link_plain -> plain)

| node | master | PR | PR + fixes |
|---|---|---|---|
| plain | false | false | false |
| uexec | true | true | true |
| gexec | false | true | true |
| oexec | false | true | true |
| suid / sticky | false | false | false |
| link_exec | true | true | true |
| link_plain | false | true | false |

(gexec/oexec flipping is the intended change i understood from your description. Same results on 0.10.4, 0.12.7 and 0.13.0-dev with the fixes)

alex-courtis alex-courtis commented on Dec 02, 2026 22:12 UTC
Author

stat.mode & 73 only parses on nightly as the LuaJIT bundled with stable doesn't support the 5.3 bitwise ops yet. So utils.lua fails to load and the tree doesn't open at all:

That jit version seems quite variable, depending on how neovim was built and how it's packaged for the OS. It's fine on 0.12.6 for me.

I did wonder why we had the extra call to fs_access, lua versions do explain it.

I'd use bit.band(stat.mode, 73) ~= 0, which works on 0.10.4, 0.12.7 and nightly just fine.

bit.band should be the safe option - it's been used in neovim stable for over a year: https://github.com/neovim/neovim/blame/d2ca90d87e3246b5b827ed08f8c0dfc8ad6ae4c8/runtime/lua/vim/glob.lua#L234

Side note: CI is 🟢 cause check / lint don't actually load the module.

Functional tests are coming... #3369 I'd be really grateful if you could take a look at that branch.

alex-courtis alex-courtis commented on Dec 02, 2026 22:16 UTC
Author

2. every symlink is now executable

> fs_stat is an lstat, and on macOS a symlink's own mode is 0777 so the mask always hits. I think that using the target stat is a decent fix:

Good catch! I didn't see that as the symlink hi group was overriding the executable one.

Link always has the target's stat so we can use that.

alex-courtis alex-courtis commented on Dec 02, 2026 23:46 UTC
Author

Many thanks for the review and test @hood

Changed:

  • use bit.band in a safe manner

  • links now show target's executable state; they never actually showed the highlight before

  • links are updated on refresh
  • A review / test would be most gratefully appreciated!

    alex-courtis alex-courtis commented on code on Dec 02, 2026 23:46 UTC
    Code Review
    lua/nvim-tree/node/file-link.lua:1
    @@ -69,7 +70,26 @@ function FileLinkNode:highlighted_name()
         str = string.format("%s%s%s", str, self.explorer.opts.renderer.icons.symlink_arrow, link_to)
       end
     
    -  return { str = str, hl = { "NvimTreeSymlink" } }
    +  local hl = {
    +    "NvimTreeSymlink",
    +    self.executable and "NvimTreeExecFile" or nil,

    This was missing.

    hood hood commented on Dec 02, 2026 23:56 UTC
    Contributor

    retested 692c6c44 on macOS, all good on 0.10.4, 0.12.7 and 0.13.0-dev! (results below)

    | node | master | 692c6c44 |
    |---|---|---|
    | plain 644 | false | false |
    | uexec 744 | true | true |
    | gexec 654 / oexec 645 | false | true |
    | suid / sticky | false | false |
    | link_exec -> uexec | true | true |
    | link_plain -> plain | false | false |
    | dir (after reload) | true | false |

    also tried doing chmod 755 plain + chmod 644 uexec with the tree open, then reloading: now plain, link_plain, uexec and link_exec all flip correctly, so update_fs_stat re-statting the target sorts out that staleness thing i mentioned. bonus: dirs don't go "executable" after a reload anymore!

    LGTM! will have a go at #3369 on macOS too

    alex-courtis alex-courtis commented on Dec 03, 2026 00:08 UTC
    Author

    LGTM! will have a go at #3369 on macOS too

    Cheers mate

    Reviewers
    Assignees
    alex-courtis alex-courtis
    Labels
    risk: low confidence: 84.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 46.8% (MEDIUM) · Higher = larger blast radius
    46.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.0% · Lower = rushed or shallow review
    84.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.5% · Safe to merge
    7.5%