You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I backspace quickly, a document that begins valid-with-respect-to-Paredit can become invalid.
Rapidity (e.g., ordinary keyboard auto-repeat) is the key. I have not seen the problem when backspacing more slowly, such as once per second. Furthermore, the problem seems more severe with relatively big documents on relatively feeble computers. The more powerful the computer or the smaller the clj file, the less likely the problem.
To reproduce the problem: Open a clj or cljs file that is well-formed with respect to Paredit. Position the cursor at a point from which you can backspace a lot. Hold down the backspace key and allow it to auto-repeat. Soon, parens will start turning red or double-quotes will be mismatched.
To reproduce the problem on a pretty good machine, I started with Calva's src/cljs-lib/test/pez_rewrite_clj/paredit_test.cljs (simply because it was already large-ish), Selected-all, and Pasted numerous times until the buffer's length was about 20,000 lines. Then I positioned the cursor near the middle of the file, after a top-level form, and held down the Backspace key. On a more modest virtual machine with 8g memory and 4 cpus, a quite average clj file of a few hundred lines is enough.
The text was updated successfully, but these errors were encountered:
Here are some factors that seem relevant to Paredit:
If an async command (registered with registerCommand) does further things asyncly (as paredit handlers do), the JavaScript interpreter may interleave them with other async work, leading to race conditions if there is any shared state, such as Paredit's tokenized document model.
Asynchronous commands, invoked in rapid succession, may appear to run "out of order" even if they fastidiously await promises. VS Code apparently does not await delivery of the promise that might be returned by an asynchronous command.
To be certain a command will run to completion before anything else happens, it can be registered with registerTextEditorCommand and do nothing asynchronously. In particular: it can manipulate the document using the TextEditorEdit that's provided as a parameter instead of obtaining a TextEditorEdit by other means.
VS Code delivers TextDocumentChangeEvent asynchronously with respect to a change in the document, even if the change itself was performed synchronously. Furthermore, VS Code may delay events and deliver them in a batch. Paredit relies on TextDocumentChangeEvent to update its tokenized document model.
A VS Code document carries a version number, monotonically increasing with edits.
When I backspace quickly, a document that begins valid-with-respect-to-Paredit can become invalid.
Rapidity (e.g., ordinary keyboard auto-repeat) is the key. I have not seen the problem when backspacing more slowly, such as once per second. Furthermore, the problem seems more severe with relatively big documents on relatively feeble computers. The more powerful the computer or the smaller the clj file, the less likely the problem.
To reproduce the problem: Open a clj or cljs file that is well-formed with respect to Paredit. Position the cursor at a point from which you can backspace a lot. Hold down the backspace key and allow it to auto-repeat. Soon, parens will start turning red or double-quotes will be mismatched.
To reproduce the problem on a pretty good machine, I started with Calva's src/cljs-lib/test/pez_rewrite_clj/paredit_test.cljs (simply because it was already large-ish), Selected-all, and Pasted numerous times until the buffer's length was about 20,000 lines. Then I positioned the cursor near the middle of the file, after a top-level form, and held down the Backspace key. On a more modest virtual machine with 8g memory and 4 cpus, a quite average clj file of a few hundred lines is enough.
The text was updated successfully, but these errors were encountered: