sveltejs / sites

Monorepo for the sites in the Svelte ecosystem
https://svelte.dev
MIT License
290 stars 123 forks source link

REPL: the "undo" keyboard shortcut may replace all the content in a file with content from another tab #456

Open li6in9muyou opened 1 year ago

li6in9muyou commented 1 year ago

reproduce

  1. go to https://svelte.dev/repl/6207fed523fa45038e285262cacee9e9
  2. you are at App.svelte initially and neither of the two tabs has star sign in it
  3. change to the a.js tab, which has "important stuff" in it
  4. press the keyboard shortcut for "undo" e.g. ctrl+z on windows

actual behaviour

Important stuff in a.js is gone, replaced by content of App.svelte. The "redo" shortcut will restore important stuff.

expected behaviour

The "undo" keyboard shortcut does nothing at step 4.

possible fix

Add entries to intercept the "undo" and "redo" commands in codemirror editor options, see below.

https://github.com/sveltejs/sites/blob/a7f6683a6b034359339492964ef170326a4cfb15/packages/repl/src/lib/CodeMirror.svelte#L167-L196