adamerose / vscode-markdown-wysiwyg

https://marketplace.visualstudio.com/items?itemName=adamerose.markdown-wysiwyg
Other
14 stars 4 forks source link

Undo (Ctrl-Z) Behavior #2

Closed sjsepan3 closed 1 year ago

sjsepan3 commented 1 year ago

Expected: Undo will reverse editing changes; continuing to Undo when original state is reached has no further effect.

Observed: Once original state is reached, further Undo will delete content.

Testing: Test file attached below; repeated tests in both apps with this extension removed (others remained) and behavior was not present.

Environment: Codium: Version: 1.74.3 Release: 23010 Commit: f8b9aeda40058455453f1298fd606caf6ff8d675 Date: 2023-01-10T19:39:41.226Z Electron: 19.1.8 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Linux x64 5.15.0-57-generic Sandboxed: No

Code: Version: 1.74.3 Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534 Date: 2023-01-09T16:57:40.428Z Electron: 19.1.8 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Linux x64 5.15.0-57-generic Sandboxed: No

System: Kernel: 5.15.0-57-generic x86_64 bits: 64 compiler: gcc v: 11.3.0 Desktop: Cinnamon 5.6.7 tk: GTK 3.24.33 wm: muffin dm: LightDM Distro: Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy Machine: Type: Desktop System: Dell product: OptiPlex 7020 v: 00 serial: Chassis: type: 6 serial: Mobo: Dell model: 0F5C5X v: A00 serial: BIOS: Dell v: A10 date: 09/22/2016 Battery: Device-1: hidpp_battery_0 model: Logitech M570 serial: charge: 25% status: Discharging CPU: Info: quad core model: Intel Core i5-4590 bits: 64 type: MCP arch: Haswell rev: 3 cache: L1: 256 KiB L2: 1024 KiB L3: 6 MiB Speed (MHz): avg: 2038 high: 3292 min/max: 800/3700 cores: 1: 1197 2: 2832 3: 3292 4: 832 bogomips: 26337 Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx Graphics: Device-1: AMD Oland [Radeon HD 8570 / R5 430 OEM R7 240/340 Radeon 520 OEM] vendor: Dell driver: radeon v: kernel pcie: speed: 8 GT/s lanes: 8 ports: active: DVI-I-1 empty: DP-1 bus-ID: 01:00.0 chip-ID: 1002:6611 Device-2: Realtek RTL2838 DVB-T type: USB driver: dvb_usb_rtl28xxu,rtl2832_sdr bus-ID: 3-8:4 chip-ID: 0bda:2838 Display: x11 server: X.Org v: 1.21.1.3 driver: X: loaded: ati,radeon unloaded: fbdev,modesetting,vesa gpu: radeon display-ID: :0 screens: 1 Screen-1: 0 s-res: 1920x1080 s-dpi: 96 Monitor-1: DVI-0 mapped: DVI-I-1 model: Acer H233H res: 1920x1080 dpi: 96 diag: 585mm (23") OpenGL: renderer: AMD OLAND (LLVM 13.0.1 DRM 2.50 5.15.0-57-generic) v: 4.5 Mesa 22.0.5 direct render: Yes Audio: Device-1: Intel 8 Series/C220 Series High Definition Audio vendor: Dell driver: snd_hda_intel v: kernel bus-ID: 00:1b.0 chip-ID: 8086:8c20 Device-2: AMD Oland/Hainan/Cape Verde/Pitcairn HDMI Audio [Radeon HD 7000 Series] vendor: Dell driver: snd_hda_intel v: kernel pcie: speed: 8 GT/s lanes: 8 bus-ID: 01:00.1 chip-ID: 1002:aab0 Sound Server-1: ALSA v: k5.15.0-57-generic running: yes Sound Server-2: JACK v: 1.9.20 running: no Sound Server-3: PulseAudio v: 15.99.1 running: yes Sound Server-4: PipeWire v: 0.3.48 running: yes Network: Device-1: Intel Ethernet I217-LM vendor: Dell driver: e1000e v: kernel port: f040 bus-ID: 00:19.0 chip-ID: 8086:153a IF: eno1 state: up speed: 1000 Mbps duplex: full mac: IF-ID-1: virbr0 state: down mac: Drives: Local Storage: total: 1.93 TiB used: 1.83 TiB (95.1%) ID-1: /dev/sda vendor: Western Digital model: WDS100T2B0A-00SM50 size: 931.51 GiB speed: 6.0 Gb/s serial: ID-2: /dev/sdb vendor: Samsung model: SSD 840 EVO 120GB size: 111.79 GiB speed: 6.0 Gb/s serial: ID-3: /dev/sdc type: USB vendor: Western Digital model: WD My Passport 25E1 size: 931.48 GiB serial: Partition: ID-1: / size: 98.44 GiB used: 29.07 GiB (29.5%) fs: ext4 dev: /dev/sdb1 ID-2: /home size: 915.82 GiB used: 702.28 GiB (76.7%) fs: ext4 dev: /dev/sda1 Swap: ID-1: swap-1 type: partition size: 11.21 GiB used: 0 KiB (0.0%) priority: -2 dev: /dev/sdb2 Sensors: System Temperatures: cpu: 29.8 C mobo: 27.8 C gpu: radeon temp: 35.0 C Fan Speeds (RPM): N/A Repos: (redacted b/c URLs not allowed) Info: Processes: 293 Uptime: 3h 52m Memory: 10.65 GiB used: 4.32 GiB (40.6%) Init: systemd v: 249 runlevel: 5 Compilers: gcc: 11.3.0 alt: 11 Client: Unknown python client inxi: 3.3.13

sjsepan3 commented 1 year ago

v1.7.4: repeating scenario, additional Undo no longer deletes content; however, document-changed indicator/badge on tab does not clear as expected. This is in contrast to the behavior when extension is not enabled or not installed.

I read the vscode issue #169921 as suggested, so I understand that there may be unintended behaviors that remain.

adamerose commented 1 year ago

document-changed indicator/badge on tab does not clear as expected

This is unrelated to this issue, but I do know what you mean. This happens because I let CKEditor5 (the WYSIWYG engine) handle the undo history rather than VS Code. So undoing back to original state is equivalent to modifying the underlying file back to original state (which VS Code still considers dirty). One fix would be better to disable undo completely for the editor and let VS Code handle it. This isn't as easy as it sounds though because what you see in the editor and file is not 1:1. For example if you open a markdown file with trailing white space at the end of a line does not get rendered as real spaces in the WYSIWYG editor (which is good - it's in line with markdown spec and consistent with the built in Markdown Preview feature in VS Code).

This would be low priority for me because the having the file marked as dirty after undoing back to its original state doesn't bother me much at all, and is the only problem with the current implementation as far as I can tell.

I think this would have to be done to get the desired behavior I mentioned in the other thread (maintaining dirty state and undo history after switching between plain and WYSIWYG editor), but as of now that wouldn't be possible because the only way to switch editors in the VS Code API seems to be closing the current editor and reopening the other one, so you'd lose undo history anyways.