Skip to content

bug: {} should be considered "no result" when returned from parser in on_output_parse #492

@jerri

Description

@jerri

Neovim version (nvim -v)

v0.11.6

Operating system/version

MacOS 26.2

Describe the bug

I tried to create a parser which only returns a result when certain strings are found in the output of a task. This way I wanted to be able to only open the output with open_output and on_result = "always" when there is actually interesting stuff happening.

Unfortunately, when I try to return {} from get_result in my parser, the on_result still gets triggered and the output is shown. I consider this a bug, because this way you can't not trigger on_result with on_output_parse. Returning nil doesn't work either, as on_pre_result expects the result to be a table, otherwise you get an error message in overseer.log.

I was able to work around the situation with if_diagnostics and just returning something in the diagnostics key, but I think returning {} as no result would make more sense.

I tried to find the issue in the code, but I am not sure why it happens. According to the code in task.lua, {} should actually be considered no result. Not sure though, what is happening.

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

With a parser like

local error_parser = {
_error_found = false
parse = function (self, line)
if line.match("Error") then
self._error_found = true
end
end,
get_result = function ()
if self._error_found then
return { error_found = true }
end
return {}
end,
reset = function ()
self._error_found = false
end
}

and used within on_output_parse as parser. Then open_output gets triggered when on_result = "always".

Expected Behavior

{} should be considered no result and open_output should not be triggered.

Minimal example file

No response

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "stevearc/dressing.nvim", config = true },
  {
    "stevearc/overseer.nvim",
    config = function()
      require("overseer").setup({
        -- add your overseer config here
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions