antonmedv/codejar

Self closing characters logic

Closed this issue · 4 comments

  1. When typing a single or double quote before the same quote, it just moves the cursor one position forward instead of typing a quote.
    Between the characters and at the end of the word, it generates two quotes, although by logic it shouldn't.

  2. When typing open bracket before any bracket, it doesn't add a close bracket. Why it is forbidden in (..()), {..{}}, [..[]], {..()}, [..{}], (..[])?
    If the cursor is before close bracket, it's most likely that the cursor is inside brackets and close bracket should be added, e.g. if (ab()),{ab : {}}, [.., []].

  3. When trying to enclose a selection in brackets there is some strange logic, it encloses the selection only on some conditions.
    In other cases, it just replaces selection by open bracket.
    Also, it allows only one enclosure of selection in quotes. But what about triple-quoted strings that some languages have?
    If the option is addClosing: true, there should be only one condition - non-empty selection.

Actually, I think to drop all this logic altogether. It's strange and only hinders devs.

The problem is not the feature itself, but implementation.
I fixed it for my project, from my point of view, it is satisfactory for C-like languages.
If you interested, take look at https://github.com/angezid/codejar/tree/self-closing-characters.

Cool. Maybe a PR?

I dropped most of this logic. So now it should behave more naturally.