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

Code before:
        }, {
          params = {
            textDocument = { uri = fake_uri },
          },
          uri = fake_uri,
          client_id = client_id,
          bufnr = diagnostic_bufnr,
        }, {})

        local push_ns = vim.lsp.diagnostic.get_namespace(client_id, false)
        local pull_ns = vim.lsp.diagnostic.get_namespace(client_id, true)

        return #vim.diagnostic.get(diagnostic_bufnr, { namespace = push_ns }),
          #vim.diagnostic.get(diagnostic_bufnr, { namespace = pull_ns }),
          #vim.diagnostic.get(diagnostic_bufnr),
          push_ns,
          pull_ns
      end)

      eq(1, push_ns_count)
      eq(0, pull_ns_count)
      eq(1, all_diags_count)
      neq(push_ns, pull_ns)
    end)

    it('uses pull request identifier to isolate pull diagnostic namespaces', function()
      local first_count, second_count, total_count, first_ns, second_ns = exec_lua(function()
        vim.lsp.diagnostic.on_diagnostic(nil, {
          kind = 'full',
          items = {
            _G.make_error('Pull Diagnostic A', 0, 0, 0, 0),
          },
        }, {
          params = {
            identifier = 'provider-a',
            textDocument = { uri = fake_uri },
          },
          uri = fake_uri,
          client_id = client_id,
          bufnr = diagnostic_bufnr,
        }, {})

        vim.lsp.diagnostic.on_diagnostic(nil, {
          kind = 'full',
          items = {},
        }, {
          params = {
            identifier = 'provider-b',
            textDocument = { uri = fake_uri },
          },
          uri = fake_uri,

Review comment (suggestion):
using the same "nonce" helps discovery

```suggestion
    it('uses pull_id to isolate pull diagnostic namespaces', function()
```

Code after:
        }, {
          params = {
            textDocument = { uri = fake_uri },
          },
          uri = fake_uri,
          client_id = client_id,
          bufnr = diagnostic_bufnr,
        }, {})

        local push_ns = vim.lsp.diagnostic.get_namespace(client_id, false)
        local pull_ns = vim.lsp.diagnostic.get_namespace(client_id, true)

        return #vim.diagnostic.get(diagnostic_bufnr, { namespace = push_ns }),
          #vim.diagnostic.get(diagnostic_bufnr, { namespace = pull_ns }),
          #vim.diagnostic.get(diagnostic_bufnr),
          push_ns,
          pull_ns
      end)

      eq(1, push_ns_count)
      eq(0, pull_ns_count)
      eq(1, all_diags_count)
      neq(push_ns, pull_ns)
    end)

    it('uses pull_id to isolate pull diagnostic namespaces', function()
      local first_count, second_count, total_count, first_ns, second_ns = exec_lua(function()
        vim.lsp.diagnostic.on_diagnostic(nil, {
          kind = 'full',
          items = {
            _G.make_error('Pull Diagnostic A', 0, 0, 0, 0),
          },
        }, {
          params = {
            identifier = 'provider-a',
            textDocument = { uri = fake_uri },
          },
          uri = fake_uri,
          client_id = client_id,
          bufnr = diagnostic_bufnr,
        }, {})

        vim.lsp.diagnostic.on_diagnostic(nil, {
          kind = 'full',
          items = {},
        }, {
          params = {
            identifier = 'provider-b',
            textDocument = { uri = fake_uri },
          },
          uri = fake_uri,