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

on_result_diagnostics_quickfix.set_empty_results not clearing diagnostics list #278

Open
iainsmith opened this issue Apr 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@iainsmith
Copy link

iainsmith commented Apr 7, 2024

Neovim version (nvim -v)

NVIM v0.9.5 Build type: Release LuaJIT 2.1.1703358377

Operating system/version

MacOS 14.4 (23E214)

Describe the bug

👋 thanks for the great plugin!

After running a failing job that correctly sets diagnostics, a second successful job does not clear out the diagnostics. Re running the initial failing job does reset the diagnostics.

IMO, this is surprising and requires scripting to workaround, which could ideally be handled by the components. Maybe this is a bug with on_result_diagnostics_quickfix.set_empty_results = true or user error.

PS.
Apologise for the minimal detail in the bug report, I'll try to follow up with some more screenshots / better reproduction steps.

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  • Using the job component configuration below, with code that won't compile.
  • Running a 1st build job (error) correctly sets quickfix list and diagnostics
  • Fix the compilation issue
  • Running a 2nd build job (success) will not clear out the existing diagnostics.
  • (Re-running the 1st failed job - does clear out diagnostics)

Expected Behavior

  • on_result_diagnostics_quickfix.set_empty_result should clear out the diagnostics of a previous job

Minimal example file

No response

Minimal init.lua

return {
  "stevearc/overseer.nvim",
  config = function()
    local overseer = require("overseer")
    overseer.setup({
      -- Aliases for bundles of components. Redefine the builtins, or create your own.
      component_aliases = {
        -- Most tasks are initialized with the default components
        default = {
          { "display_duration", detail_level = 2 },
          "on_output_summarize",
          "on_exit_set_status",
          "on_complete_notify",
          "on_complete_dispose",
          { "on_output_quickfix", open_on_match = true, items_only = true, set_diagnostics = true },
          { "on_result_diagnostics", remove_on_restart = true },
          { "on_result_diagnostics_quickfix", set_empty_results = true },
        },
      },
    })
  end,
}


## Example job config

```yaml
on_output_quickfix (Set all task output into the quickfix (on complete))
  close: false
  open: false
  tail: true
  errorformat: %f:%l:%c: error: %m
  items_only: true
  set_diagnostics: true
  open_on_exit: never
  open_on_match: true
on_result_diagnostics (If task result contains diagnostics, display them)
  remove_on_restart: true
on_result_diagnostics_quickfix (If task result contains diagnostics, add them to the quickfix)
  close: false
  open: false
  use_loclist: false
  set_empty_results: true
Result:
  diagnostics = {}

Additional context

No response

@iainsmith iainsmith added the bug Something isn't working label Apr 7, 2024
@stevearc
Copy link
Owner

stevearc commented Jun 6, 2024

I cannot replicate this. I'm using this task

overseer.register_template({
  name = "quickfix",
  builder = function()
    return {
      cmd = "./quick.sh",
      components = {
        "default",
        { "on_output_quickfix", open_on_match = true, items_only = true, set_diagnostics = true },
        { "on_result_diagnostics", remove_on_restart = true },
        { "on_result_diagnostics_quickfix", set_empty_results = true },
      },
    }
  end,
})

With this helper script as quick.sh

#!/bin/bash
echo 'lua/overseer/init.lua:22: error: this is an error'
echo 'lua/overseer/init.lua:44: error: this is an error'
# echo "success"

I run the task once, see the quickfix populated, comment/uncomment the quick.sh script to have it output no errors, then run a new task. The quickfix gets cleared for me.

Can you provide a minimal configuration that reproduces the issue?

@stevearc stevearc added the question Further information is requested label Jun 6, 2024
@lalitmeek
Copy link

Hey @stevearc, I am also facing the same issue with yarn tsc-watch command.

I am using the following template for the task:

local tsc_errorformat = {
    "%E%f:%l:%c: error %m", -- Error: file, line, column, message
    "%E%f:%l:%c - error %m", -- Another common error format (seen in newer versions)
    "%C%m", -- Continued error messages
    "%-G%.%#", -- Ignore any other lines
}

return {
    name = "yarn-tsc-watch",
    builder = function()
        return {
            cmd = "yarn",
            args = { "tsc-watch" },
            cwd = vim.fn.getcwd(),
            name = "yarn-tsc-watch",
            components = {
                { "on_output_quickfix", set_diagnostics = true, open = false, errorformat = table.concat(tsc_errorformat, ","), open_on_match = true, close = true },
                { "on_result_diagnostics", remove_on_restart = true },
                { "on_result_diagnostics_quickfix", close = true, open = true, set_empty_result = true },
                { "on_result_notify", system = "unfocused" },
                "default",
            },
        }
    end,
    desc = "Run TypeScript compiler in watch mode (yarn tsc-watch)",
    condition = {
        callback = function()
            return vim.fn.filereadable("package.json") == 1
        end,
    },
}

@github-actions github-actions bot removed the question Further information is requested label Aug 21, 2024
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