fix: prevent infinite loop when started from non-filesystem buffer #35

Merged
barrettruth merged 5 commits from fix/oil-infinite-loop into main 2026-03-06 16:58:46 +00:00
barrettruth commented 2026-03-06 16:51:43 +00:00

Problem

Calling `:LiveServerStart` from an oil.nvim buffer (or any URI-scheme buffer) caused two issues: first, `find_cached_dir` entered an infinite loop as `fnamemodify(cur, ':h')` degenerated to `.`, freezing Neovim and pegging the CPU; second, even after fixing the loop, the server would error out instead of doing the right thing — serving the directory being browsed.

Solution

Add a progress check to `find_cached_dir` so it bails if the path stops changing. Fix `resolve_dir` to detect URI-scheme buffer names (e.g. `oil:///path/to/dir`) and extract the real filesystem path from them, so `:LiveServerStart` correctly serves the browsed directory. Also corrects the bug report repro template (`require('lazy')`, `lazy = false`, no deprecated `opts`) and ignores `repro.lua`.

Closes #34

## Problem Calling \`:LiveServerStart\` from an oil.nvim buffer (or any URI-scheme buffer) caused two issues: first, \`find_cached_dir\` entered an infinite loop as \`fnamemodify(cur, ':h')\` degenerated to \`.\`, freezing Neovim and pegging the CPU; second, even after fixing the loop, the server would error out instead of doing the right thing — serving the directory being browsed. ## Solution Add a progress check to \`find_cached_dir\` so it bails if the path stops changing. Fix \`resolve_dir\` to detect URI-scheme buffer names (e.g. \`oil:///path/to/dir\`) and extract the real filesystem path from them, so \`:LiveServerStart\` correctly serves the browsed directory. Also corrects the bug report repro template (\`require('lazy')\`, \`lazy = false\`, no deprecated \`opts\`) and ignores \`repro.lua\`. Closes #34
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
barrettruth/live-server.nvim!35
No description provided.