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

Wrong "automatic bracket closing" behaviour? #21

Open
MrCoder opened this issue Jul 27, 2023 · 4 comments
Open

Wrong "automatic bracket closing" behaviour? #21

MrCoder opened this issue Jul 27, 2023 · 4 comments

Comments

@MrCoder
Copy link

MrCoder commented Jul 27, 2023

According to the specification (https://codemirror.net/docs/ref/#autocomplete.closeBrackets), the default "automatic bracket closing" should be like this:

  1. type (, then ) is automatically inserted;
  2. type ), the cursor moves over that bracket.

The example has the same behaviour as explained: https://codemirror.net/try/

It does not seem to work in the same way at https://logue.dev/vue-codemirror6/ with basic lang=javascript.

Specifically, the second step, when you type ), the character is inserted.

@logue
Copy link
Owner

logue commented Jul 28, 2023

It's still under testing, but it seems to work in the "Linter and cross binding demo" with the update I just committed.

@dyon21
Copy link
Contributor

dyon21 commented Jul 28, 2023

Currently, when you input "()", you get "())", which does not follow the specification.

https://github.com/logue/vue-codemirror6/blob/master/src/components/CodeMirror.ts#L442
I found that this watcher updates the CodeMirror content even if the update is exactly caused by CodeMirror itself, this might making CodeMirror think there are additional manipulations between the two input( ( and ) ), so it will not trigger the second step.

It is necessary to check the update source, If the update comes from CodeMirror, then don't dispatch the update back to CodeMirror.

I have fixed it in #22

@MrCoder
Copy link
Author

MrCoder commented Jul 29, 2023

Hi @logue, do mind merging @dyon21 's PR #22 ? I have tested it and that works very well. I have a product that uses this component. It is much appreciated if the fix is released as soon as possible.

@logue
Copy link
Owner

logue commented Aug 2, 2023

Merged.
There are also cases where you use it to customize the line separator, so we also fixed that.

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

No branches or pull requests

3 participants