Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

fix issue 8395#8426

Closed
mackenza wants to merge 1 commit intoadobe:masterfrom
mackenza:issue-8395
Closed

fix issue 8395#8426
mackenza wants to merge 1 commit intoadobe:masterfrom
mackenza:issue-8395

Conversation

@mackenza
Copy link
Copy Markdown
Contributor

This is a PR to address #8395

I am not super happy about testing the nonWS again as is done below in the || comparison but I couldn't immediately think of a better way to do this.

As per the issue discussion, if the line has non-whitespace characters, the whitespace is not stripped.

Comment thread src/editor/Editor.js
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick drive-by comment: this may need to be batched with the other operation to avoid creating two separate Undo steps. But the other operation is done on a timeout, which means we'd need to figure out a different fix that can occur after the '}' is typed rather than before. Maybe after the indentLine() call, we could check if the rest of the line is nothing but whitespace, and remove it if so? then the indentLine() & replaceRange() calls could be grouped together in a batch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does one batch commands so that they aren't separate undo ops?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally document.batchOperation(), but within Editor it looks like we call the raw cm.operation() directly instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mackenza As I suggested in IRC, maybe moving cursor to end of (whitespace-only) line before performing edit is a simpler solution.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will give it a look.

@mackenza
Copy link
Copy Markdown
Contributor Author

problems with git so I had to recreate my fork and thus this PR is orphaned. I will close this and open a new one for this issue.

Sorry for being such a git noob ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants