Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For #2691, stabilize deleteForward by reducing asyncness #2692

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

pbwolf
Copy link

@pbwolf pbwolf commented Jan 4, 2025

This is a small addition to the backspace PR, doing the same for deleteForward.

What has changed?

  • The deleteBackward PR is included in this PR
  • deleteForward is registered with registerTextEditorCommand and does not await anything
  • deleteForward skips reformatting
  • 'async' and 'await' are removed from tests of deleteForward
  • EditableDocument.delete, a disused subroutine of deleteForward, is removed

The reason to skipFormat is: formatting moves the selection past commas, which in combination with deleteForward makes commas resist deletion! This interplay is newly exposed by the non-async deleteForward. The (prior) async deleteForward async'ly moved the selection, which "undid" formatting's selection if the timing worked out right.

Fixes #2691 and #2611

My Calva PR Checklist

I have:

  • Read How to Contribute.
  • Directed this pull request at the dev branch. (Or have specific reasons to target some other branch.)
  • Made sure I have changed the PR base branch, so that it is not published. (Sorry for the nagging.)
  • Made sure there is an issue registered with a clear problem statement that this PR addresses, (created the issue if it was not present).
    • Updated the [Unreleased] entry in CHANGELOG.md, linking the issue(s) that the PR is addressing.
  • Figured if anything about the fix warrants tests on Mac/Linux/Windows/Remote/Whatever, and either tested it there if so, or mentioned it in the PR.
  • N/A Added to or updated docs in this branch, if appropriate
  • Tests
    • Tested the particular change
    • Figured if the change might have some side effects and tested those as well.
  • Formatted all JavaScript and TypeScript code that was changed. (use the prettier extension or run npm run prettier-format)
  • Confirmed that there are no linter warnings or errors (use the eslint extension, run npm run eslint before creating your PR, or run npm run eslint-watch to eslint as you go).

Ping @PEZ, @bpringe, @corasaurus-hex, @Cyrik

Copy link

netlify bot commented Jan 4, 2025

Deploy Preview for calva-docs ready!

Name Link
🔨 Latest commit da7d69e
🔍 Latest deploy log https://app.netlify.com/sites/calva-docs/deploys/677c703f97221e000841c725
😎 Deploy Preview https://deploy-preview-2692--calva-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@pbwolf pbwolf marked this pull request as draft January 5, 2025 20:34
@PEZ
Copy link
Collaborator

PEZ commented Jan 6, 2025

Thanks so much for contributing this work, @pbwolf! And thanks for researching throughly and detailing the rationale for the changes. It all makes sense, I think. The only thing I wonder about is why we call it Now and non-async, instead of just sync, as is the pattern in JS land. But we can change that later.

It looks ready to merge, but the PRs are both marked Draft. Is there something you still want to change, @pbwolf?

@pbwolf pbwolf marked this pull request as ready for review January 7, 2025 00:07
@pbwolf
Copy link
Author

pbwolf commented Jan 7, 2025

I restored the reformat-as-you-type in deleteForward for symmetry with deleteBackward: upon removing an empty list, it reformats. This can cause a strange cursor move, but I am not sure whether the answer is for deleteForward not to reformat or for reformatting not to move the cursor. There is a logic branch in the reformatting devoted specifically to moving the cursor if reformatting did not change the document. For example: |(),,,(), del, del, and suddenly the cursor scoots over the commas: ,,,|()

@skylize
Copy link
Contributor

skylize commented Jan 7, 2025

~~Maybe I'm alone here? I think this should be viewed as a workaround, rather than a fix. We should hope at some point someone might be able to come back later and make things work both in-order and async.

Please don't let that come across as any sort of disagreement with going through on the patch. A successful workaround is still successful.~~

Thanks for the work.

Edit:

A pattern is established for non-async command handlers that run faster and expose themselves less to the risk of race conditions. This will be helpful for commands that might be issued rapidly, such as backspace

I might take that back? Seems I was talking without enough knowledge on the topic, so can't say for sure. In whatever, case thanks again for the hard work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants