VSCodeVim / VSCodeVim/Vim

find-and-replace has strange behavior within macros

Open
#8,268 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Type: Bug

Describe the bug
I recently had to convert a large number of camel-cased names to all-caps snake-case, and was quickly making a macro to do this for me. It wasn't complicated - 0ve:s/[A-Z]/_&/g^MveUj - but whenever I tried to replay it, it would perform the replacement on the same line as I originally recorded the macro, no matter where I was in the file. When I had other commands before and after the replace, the ones before would execute normally, but the ones after would execute on the original line, just like the replacement.

To Reproduce

  1. record a macro that replaces within a selection.
  2. replay this macro elsewhere in the file.

Expected behavior
All macro commands should execute relative to the cursor position at which the macro is invoked.

Extension version: 1.24.3
VS Code version: Code 1.75.1 (Universal) (441438abd1ac652551dbe4d408dfcec8a499b8bf, 2023-02-08T21:34:59.000Z)
OS version: Darwin arm64 22.3.0
Modes:
Sandboxed: No

System Info
Item Value
CPUs Apple M1 Max (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 2, 2, 2
Memory (System) 32.00GB (0.66GB free)
Process Argv --crash-reporter-id 81804ef4-ebdd-4184-bf3f-a4207b956fc3
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30669237
azure-dev_surveyone:30548225
pyindex848:30662994
nodejswelcome1:30587005
2e4cg342:30602488
pyind779:30662992
89544117:30613380
pythonsymbol12cf:30657549
a9j8j154:30646983
vsccsb:30662443

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported macro with find-and-replace in VS Code using the VSCodeVim extension, then trace macro replay and replacement handling from the relevant entry points. Done means every command, including replacement, runs relative to the cursor where the macro is invoked, with a regression test covering replay elsewhere in the file.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vim, vscode
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.