Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always getting "No Committed Yet" on Windows 10 #147

Open
LizardLiang opened this issue Dec 10, 2024 · 1 comment
Open

Always getting "No Committed Yet" on Windows 10 #147

LizardLiang opened this issue Dec 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@LizardLiang
Copy link

LizardLiang commented Dec 10, 2024

Hi,
I encountered this issue on my Windows 10 machine running Neovim (version details below):

NVIM v0.11.0-dev-1325+g30726c778c
Build type: RelWithDebInfo
LuaJIT 2.1.1732813678

Investigation revealed that the M.get_repo_root function was failing due to issues with the && operator. Instead of using cd to change the working directory, I resolved this by adding it to the cwd field in vim.fn.jobstart options:

-- git.lua
---@param callback fun(repo_root: string)
function M.get_repo_root(callback)
    if not utils.get_filepath() then
        return
    end
    local command = "git rev-parse --show-toplevel"

    utils.start_job(command, {
        on_stdout = function(data)
            callback(data[1])
        end,
    })
end

-- utils.lua
function M.start_job(cmd, opts)
       opts = opts or {}

    local jobstart_options = {
        stdout_buffered = true,
        ---@param data string[]
        on_stdout = function(_, data, _)
            if data and opts.on_stdout then
                opts.on_stdout(data)
            end
        end,
        on_exit = function(_, code, _)
            if opts.on_exit then
                opts.on_exit(code)
            end
        end,
    }

    if vim.fn.getftype(vim.fn.expand("%:p:h")) == "file" then
        jobstart_options.cwd = vim.fn.expand("%:p:h")
    end

    local id = vim.fn.jobstart(cmd, jobstart_options)

    if opts.input then
        vim.fn.chansend(id, opts.input)
        vim.fn.chanclose(id, "stdin")
    end

    return id
end

This modification seems to resolve the issue

@jordansmith28
Copy link

I believe this issue is not limited to Windows 10. Currently on MacOS (Sonoma 14.5) with Nvim version below and seeing the same problem happen

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1720049189

@f-person f-person added the bug Something isn't working label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants