CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

[WIP] Automatic forward on autocompletion pairs

Open jevonmao opened this issue 3 years ago • 11 comments

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

jevonmao avatar May 18 '22 20:05 jevonmao

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

lilingxi01 avatar May 19 '22 04:05 lilingxi01

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.

@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.

austincondiff avatar May 19 '22 04:05 austincondiff

@lilingxi01 @lukepistrol @lilingxi01 I will try to do the counting and auto adding in this PR, working in progress.

jevonmao avatar May 20 '22 19:05 jevonmao

@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 avatar May 20 '22 22:05 jevonmao

@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?

austincondiff avatar May 20 '22 22:05 austincondiff

Ok yes that made sense, thank you

jevonmao avatar May 20 '22 22:05 jevonmao

Not a problem!

austincondiff avatar May 20 '22 22:05 austincondiff

Any updates on this? Please consider implementing this functionality in CodeEditTextView

lukepistrol avatar Jun 10 '22 15:06 lukepistrol

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.

0xWDG avatar Jun 22 '22 14:06 0xWDG

@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 avatar Jun 27 '22 23:06 jevonmao

@jevonmao Yeah, I think that is best at this point. Thanks!

austincondiff avatar Jun 28 '22 03:06 austincondiff