[WIP] Automatic forward on autocompletion pairs
Description
Currently, an issue with the pair autocompletion is that when you type the closing character, it will duplicate. For example, you type (, it completes to (), and if you type ), it will become ()) which is undesirable. This PR fixes this issue and automatically skips the closing character, forwarding the cursor. This behavior is standard across all code editors and IDEs, including Xcode.
Checklist
- [x] I read and understood the contributing guide as well as the code of conduct
- [x] My changes generate no new warnings
- [x] My code builds and runs on my machine
- [x] I documented my code
- [x] Review requested
Just a note: In most IDEs (e.g. WebStorm, Xcode), the auto-forwarding of closing parenthesis is actually based on the count of parenthesis.
In the case of abc(()[cursor]), when I type ), it will be abc(())[cursor] (forwarding). In this PR, it works great.
In the case of abc(([cursor]), when I type ), it should be abc(()[cursor]) (adding) rather than abc(()[cursor] (forwarding). In this PR, it does not support.
For this PR, the fix is great, but we should also consider implement this functionality (probably not in this PR though, could be in the future). @austincondiff
In the case of
abc(([cursor]), when I type), it should beabc(()[cursor])(adding) rather thanabc(()[cursor](forwarding). In this PR, it does not support.
@lilingxi01 I completely agree with this. @jevonmao If you can do this in this PR, great, but if you’d rather we can do this in a future PR.
@lilingxi01 @lukepistrol @lilingxi01 I will try to do the counting and auto adding in this PR, working in progress.
@lilingxi01 I understand what you mean, but can you clarify the case where it's supposed to be adding? Maybe record a video or something?
@jevonmao I will use | to represent the cursor. In the following scenario: abc((|)
When you type type ), it should be abc(()|) rather than abc(()| because there is still an additional open (.
Does this make sense?
Ok yes that made sense, thank you
Not a problem!
Any updates on this? Please consider implementing this functionality in CodeEditTextView
This PR is a fix for this issue: https://github.com/CodeEditApp/CodeEditTextView/issues/23
@jevonmao Any updates on this issue? As Like already said, maybe it's better to implement this in the new editor.
@wdg I agree, it's probably best to re-implement this feature in the new CodeEditTextView library. Again, my apologies for the long hiatus on the progress. Should I close this and reopen in the other repo?
@jevonmao Yeah, I think that is best at this point. Thanks!