Repository: neovim/neovim
File: test/functional/lua/diagnostic_spec.lua (Lua)

Code before:
  describe('toqflist() and fromqflist()', function()
    it('works', function()
      local result = exec_lua(function()
        vim.diagnostic.set(_G.diagnostic_ns, _G.diagnostic_bufnr, {
          _G.make_error('Error 1', 0, 1, 0, 1),
          _G.make_error('Error 2', 1, 1, 1, 1),
          _G.make_warning('Warning', 2, 2, 2, 2),
        })

        local diagnostics = vim.diagnostic.get(_G.diagnostic_bufnr)
        vim.fn.setqflist(vim.diagnostic.toqflist(diagnostics))
        local list = vim.fn.getqflist()
        local new_diagnostics = vim.diagnostic.fromqflist(list)

        -- Remove extra properties not present in the return value of fromlist()
        for _, v in ipairs(diagnostics) do
          v._extmark_id = nil
          v.namespace = nil
        end

        return { diagnostics, new_diagnostics }
      end)
      eq(result[1], result[2])
    end)

    it('merges continuation lines when merge_lines is true', function()
      local result = exec_lua(function()
        local qflist = {
          {
            bufnr = 1,
            lnum = 10,
            col = 5,
            end_lnum = 10,
            end_col = 10,
            text = 'error: [GHC-83865]',
            type = 'E',
            nr = 0,
            valid = 1,
          },
          {
            bufnr = 1,
            lnum = 0,
            col = 0,
            end_lnum = 0,
            end_col = 0,
            text = "    Couldn't match expected type",
            type = '',
            nr = 0,
            valid = 0,
          },
          {

Review comment (suggestion):
```suggestion
    it('merge_lines=true merges continuation lines', function()
```

Code after:
  describe('toqflist() and fromqflist()', function()
    it('works', function()
      local result = exec_lua(function()
        vim.diagnostic.set(_G.diagnostic_ns, _G.diagnostic_bufnr, {
          _G.make_error('Error 1', 0, 1, 0, 1),
          _G.make_error('Error 2', 1, 1, 1, 1),
          _G.make_warning('Warning', 2, 2, 2, 2),
        })

        local diagnostics = vim.diagnostic.get(_G.diagnostic_bufnr)
        vim.fn.setqflist(vim.diagnostic.toqflist(diagnostics))
        local list = vim.fn.getqflist()
        local new_diagnostics = vim.diagnostic.fromqflist(list)

        -- Remove extra properties not present in the return value of fromlist()
        for _, v in ipairs(diagnostics) do
          v._extmark_id = nil
          v.namespace = nil
        end

        return { diagnostics, new_diagnostics }
      end)
      eq(result[1], result[2])
    end)

    it('merge_lines=true merges continuation lines', function()
      local result = exec_lua(function()
        local qflist = {
          {
            bufnr = 1,
            lnum = 10,
            col = 5,
            end_lnum = 10,
            end_col = 10,
            text = 'error: [GHC-83865]',
            type = 'E',
            nr = 0,
            valid = 1,
          },
          {
            bufnr = 1,
            lnum = 0,
            col = 0,
            end_lnum = 0,
            end_col = 0,
            text = "    Couldn't match expected type",
            type = '',
            nr = 0,
            valid = 0,
          },
          {