CodeEditApp / CodeEditSourceEditor

A code editor view written in Swift powered by tree-sitter.
https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor
MIT License
514 stars 80 forks source link

✨ Autocomplete angle bracketed components the same way braces are autocompleted #244

Closed knotbin closed 4 months ago

knotbin commented 5 months ago

Description

When a user uses angle brackets with a component, for instance typing <div>, and then presses enter, the system autocompletes that component, adding </div> on the line below the new current line and indents the new current line.

Alternatives Considered

No response

Additional Context

No response

Screenshots

Screenshot 2024-04-27 at 2 10 06 PM
austincondiff commented 5 months ago

This should probably only apply to html, xml, and jsx. It should work like this…

  1. User types < - no autocomplete occurs
  2. User types tag name, <div - no autocomplete occurs
  3. User types >, <div> - closing tag is autocomplete and is inserted directly after the opening tag. Cursor is placed in between tags. Eg. <div>|</div>
  4. If user presses return, closing tag is moved to a new line, then cursor is placed on a new empty line and indented in between the other two lines. Eg…
    <div>
    |
    </div>

[!NOTE] Tag attributes should be ignored and not put in the closing tag. Eg. <div class="panel"></div>

knotbin commented 5 months ago

In addition to JSX and TSX, it should also apply to regular JS and TS files as JSX and TSX can be written inside regular JS and TS files.

austincondiff commented 4 months ago

@knotbin absolutely, good point! Would you be willing to take this one on?

knotbin commented 4 months ago

Sure @austincondiff!

austincondiff commented 4 months ago

You rock! Several additional considerations...