Global regex search with "Not matching character" doesn't match newline
See original GitHub issueIssue Type: Bug
I was trying to search for
Promise\.all\(\[[^\]]*await[^\]]*\]\)
but I had no way to turn on multiline support so that ^\]
would match newlines too. So searching for below would not be found.
return await Promise.all([
await this.someFunction1(),
await this.someFunction2(),
]);
I later put in the below and was happy to find that it suddely worked, but knew that it would only find if await was on the first line after the bracket, and also if there was no chars other than newline space or tab.
Promise\.all\(\[[^\]]*[\n\r \t]await[^\]]*\]\)
But, I then started to find others that actually SHOULDN’T have worked…
It was at this point, I realsed that ^\]
was working as expected the first time, and was matching on newline chars… (Perfect, I removed my tab/space hack)… To find, it stopped working again…
It seems I need atleast 1 \n
in the regex to make it work.
My quick fix was to add this at the very end as such
Promise\.all\(\[[^\]]*await[^\]]*\]\)\n{0}
But this is obviously a dirty hack and not an obvious one, be far better to test for Not Matching
and turn multiline back on, similar to what ever test you are doing for searching for \n
and turning on multiline
VS Code version: Code 1.35.0 (553cfb2c2205db5f15f3ee8395bbd5cf066d357d, 2019-06-04T01:17:12.481Z) OS version: Windows_NT x64 10.0.10240
System Info
Item | Value |
---|---|
CPUs | Intel® Xeon® CPU E5-1620 v3 @ 3.50GHz (8 x 3492) |
GPU Status | 2d_canvas: enabled checker_imaging: disabled_off flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on native_gpu_memory_buffers: disabled_software rasterization: enabled surface_synchronization: enabled_on video_decode: enabled webgl: enabled webgl2: enabled |
Load (avg) | undefined |
Memory (System) | 15.92GB (5.33GB free) |
Process Argv | |
Screen Reader | no |
VM | 0% |
Extensions (19)
Extension | Author (truncated) | Version |
---|---|---|
markdown-preview-github-styles | bie | 0.1.6 |
npm-intellisense | chr | 1.3.0 |
ssh | chr | 0.0.4 |
vue-peek | dar | 1.0.2 |
vscode-eslint | dba | 1.9.0 |
vscode-ts-auto-return-type | ebr | 1.0.1 |
tslint | eg2 | 1.0.43 |
RunOnSave | eme | 0.0.18 |
prettier-vscode | esb | 1.9.0 |
todo-tree | Gru | 0.0.134 |
node-module-intellisense | lei | 1.5.0 |
camelcasenavigation | map | 1.0.1 |
rainbow-csv | mec | 1.1.1 |
node-modules-resolve | nau | 1.0.2 |
uuid-generator | net | 0.0.4 |
vetur | oct | 0.21.0 |
gitconfig | sid | 2.0.0 |
open-in-browser | tec | 2.0.0 |
sort-lines | Tyr | 1.8.0 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:22 (4 by maintainers)
Top GitHub Comments
I just use
\n{0}
a the end of all my searches… been working fine so far…Then 👍 Big thumbs up that
[^s]
should indeed turn that mode on… Ok… I am up to date and agreeing. Good job everyone… take a 5 minute break and enjoy your evening.