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

Reduce unnecessary updates #22

Merged
merged 1 commit into from
Aug 1, 2023
Merged

Reduce unnecessary updates #22

merged 1 commit into from
Aug 1, 2023

Conversation

dyon21
Copy link
Contributor

@dyon21 dyon21 commented Jul 28, 2023

No description provided.

// IME fix
if (
view.value.composing || // IME fix
view.value.state.doc.toJSON().join('\n') === value // don't need to update
Copy link

Choose a reason for hiding this comment

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

This can be simplified as view.value.state.doc.toString() === value according to https://codemirror.net/docs/ref/#state.Text.toString.

Copy link

Choose a reason for hiding this comment

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

Note, 1. toString is only added to index.d.ts 6.2.x though it works fine on 6.1.4; 2. regardless the version, ESLint will (wrongly?) report error no-base-to-string.

Copy link
Contributor Author

@dyon21 dyon21 Jul 28, 2023

Choose a reason for hiding this comment

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

It works well but I got a warning, seems there are some type definition issues

image

Copy link

Choose a reason for hiding this comment

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

yeah, I noticed the same issue. Actually, I commented after I found the issue but forgot the commit the comment :)

Copy link
Contributor Author

@dyon21 dyon21 Jul 28, 2023

Choose a reason for hiding this comment

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

Then should we still use it like (view.value.state.doc as any).toString()? I would prefer the current one, we can fix it after bumping the version.

@logue logue merged commit cb71f3c into logue:master Aug 1, 2023
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