formulahendry / vscode-auto-rename-tag

Automatically rename paired HTML/XML tag
https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-rename-tag
MIT License
259 stars 36 forks source link

Cutting or deleting opening tag content causes undo loop #608

Open phoenixeliot opened 2 years ago

phoenixeliot commented 2 years ago

Issue Type: Bug

Write this in a TSX file:

function Foo() {
  return <div className="stuff">
  </div>
}

Select div className="stuff" Cut with cmd-x Undo with cmd-z Undo again with cmd-z Undo again with cmd-z

Result: Instead of undoing the cut, it simply toggles between these two states forever, and blocks off all undo history before this action:

function Foo() {
  return <div>
  </div>
}
function Foo() {
  return <>
  </>
}

I suspect what's happening is that undoing is causing the extension to trigger a change, which is triggering a new action to be pushed onto the undo stack.

Slightly different results happen if you delete instead of cut:

function Foo() {
  return <div className="">
  </div>
}
function Foo() {
  return < className="">
  </>
}

And if the opening and closing tags are on the same line, it behaves in a more complex but still incorrect fashion.

Extension version: 0.1.10 VS Code version: Code 1.66.2 (Universal) (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:49:20.994Z) OS version: Darwin arm64 21.4.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (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
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|7, 5, 4| |Memory (System)|32.00GB (1.48GB free)| |Process Argv|--crash-reporter-id 18db7754-a899-47ab-9295-2cc481e3630e| |Screen Reader|yes| |VM|0%|
phoenixeliot commented 2 years ago

Dupe of #588 #565 and possibly #55