### Bug description

Hello,

Apparently images ref completion does not work when using listings (**VSCode 1.71.0, Windows 10 64 bit**). Here is the message : 
```
[Error - 15:06:20] Request textDocument/completion failed.
  Message: Request textDocument/completion failed with message: Command failed: 
Programs\Quarto\bin\tools\pandoc --defaults defaults.yml
Error running filter Programs/Quarto/share/filters/crossref/crossref.lua:
...ocal/Programs/Quarto/share/filters/crossref/crossref.lua:1939: attempt to index a nil value (field 'text')
stack traceback:
	...ocal/Programs/Quarto/share/filters/crossref/crossref.lua:1154: in function <...ocal/Programs/Quarto/share/filters/crossref/crossref.lua:1148>

  Code: -32603 
```

And here is a minimal working example :

```
---
title: "Bug quarto"
format:
  html:
    code-fold: true
jupyter: python3
---

For a demonstration of a line plot on a polar axis, see @fig-countour.
Figure autocompletion works without listing see @lst-test.

Carefull, I replaced ``` with """ to enable a preview.

'''{#lst-test .py lst-cap="This is a test"}
x = 1
'''

'''{python}
#| label: fig-countour
#| fig-cap: "A line plot on a polar axis"

import numpy as np
import matplotlib.pyplot as plt

def draw_fig():
  N = 256
  x = np.linspace(-20,20,551)
  y = np.linspace(-20,20,551)
  X, Y = np.meshgrid(x,y)
  Z = 4*X**2 + Y**2
  fig, ax = plt.subplots()
  X, Y = np.meshgrid(x, y)
  p = ax.contourf(X, Y, Z, N, cmap='jet')
  fig.colorbar(p)
  ax.grid(ls=':')
  ax.set_aspect('equal')
  ax.set_xlabel("x")
  ax.set_ylabel("y")
  ax.set_title("a graph")

draw_fig()
'''
```

Thank a lot for your hardwork on quarto, I am found of this tool.

Best regards,

Roman

### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
jjallaire
2022-09-13T13:17:54Z
RomanLF
bug needs-repro crossref
v1.2
closed
cross-ref on VScode: figure ref autocompletion not working when using a listing
https://github.com/quarto-dev/quarto-cli/issues/2421