Repository: vscode
Issue: Regex match doesn't start at cursor
Labels: bug,editor-find

Type: <b>Bug</b>

Here's the text i'm searching:

```md
([foo](foo))

(bar)
```

The search pattern is this:

```regex
(\()(.+?)(\))
```

The cursor position is after the right square bracket, i.e., just left of what I expect to the 1st match ```(foo)```.

When I execute this search, it correctly sees two matches, but it goes to the 2nd match ```(bar)``` first. I expect it to go to the 1st match ```(foo)``` first. If I place the cursor outside the 1st parens, i.e. left of ```([foo]```, and execute the search then I see the expected behavior.

VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:13:33.891Z)
OS version: Windows_NT x64 10.0.22631
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx   (8 x 2296)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled|
|Load (avg)|undefined|
|Memory (System)|61.95GB (36.83GB free)|
|Process Argv|--crash-reporter-id f4d11365-b8df-4076-a7d2-5647e124f85c|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (54)</summary>

Extension|Author (truncated)|Version
---|---|---
increment-selection|alb|0.2.0
Bookmarks|ale|13.5.0
html-end-tag-labels|ant|1.0.0
sort-editors|asw|2.0.1
markdown-footnotes|bie|0.1.1
markdown-toc|Cha|1.5.6
vscode-markdownlint|Dav|0.55.0
vscode-eslint|dba|2.4.4
githistory|don|0.6.20
xml|Dot|2.5.1
overtype|DrM|0.5.0
vsc-material-theme-icons|equ|3.6.0
url-encode|fle|1.1.0
html-preview-vscode|geo|0.2.5
live-sass|gle|6.1.2
todo-tree|Gru|0.0.226
vscode-html-validate|htm|2.8.2
markdown-extended|jeb|1.1.4
docomment|k--|1.0.0
wordcounter|kir|2.4.4
csharpextensions|kre|1.7.3
vscode-autohotkey-plus-plus|mar|5.0.3
markdown-shortcuts|mdi|0.12.0
rainbow-csv|mec|3.11.0
render-crlf|med|1.8.1
csdevkit|ms-|1.6.8
csharp|ms-|2.30.28
vscode-dotnet-runtime|ms-|2.0.5
vscodeintellicode-csharp|ms-|2.1.11
powershell|ms-|2024.2.2
csv-to-md-table|pho|0.3.1
material-icon-theme|PKi|5.3.0
word-counter|plu|0.0.1
toggle|reb|0.0.2
vscode-xml|red|0.26.1
vscode-yaml|red|1.14.0
vscode-sort-json|ric|1.20.0
block-travel|sas|0.0.2
vscode-table-formatter|shu|1.2.1
some-sass|Som|3.1.4
code-spell-checker|str|3.0.1
code-spell-checker-british-english|str|1.4.8
code-spell-checker-french|str|0.4.1
code-spell-checker-german|str|2.3.2
code-spell-checker-greek|str|1.2.2
code-spell-checker-italian|str|1.1.1
code-spell-checker-medical-terms|str|3.0.2
code-spell-checker-scientific-terms|str|0.2.2
code-spell-checker-spanish|str|2.3.4
vscode-icons|vsc|12.7.0
whichkey|VSp|0.11.4
copyrawvalue|wer|1.0.0
deletehere|xin|0.0.1
markdown-all-in-one|yzh|3.6.2

(1 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

```
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:31000450
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
chatpanelt:31048053
dsvsc021:30996838
f3je6385:31013174
pythoncenvptcf:31049071
a69g1124:31058053
dvdeprecation:31052039
pythonprt:31056678
dwnewjupyter:31046869
26j00206:31048877

```

</details>

<!-- generated by issue reporter -->