Thom1729 / Sublime-JS-Custom

Customizable JavaScript syntax highlighting for Sublime Text.
MIT License
137 stars 9 forks source link

JSX Close Tag Ignoring Already Closed Tags #123

Closed dndrsn closed 2 years ago

dndrsn commented 3 years ago

The JSX close tag logic appears to be ignoring already closed tags when determining the tag to be closed. Instead it closes the "most recent" previously opened tag. Take the following snippet for example:

const Test = () => (
  <div>
    <h1>a heading</h1>

   // Close tag command will insert another </h1> instead of a </div> here

    <p>testing <span>closing tag</span></p>

  // Close tag command will insert another </span> instead of a </div> here
);

The close tag logic will close at the end with a </span> instead of a </div>.

Using Sublime 4107. This had always worked previously and seems to have been introduced with a newer version of Sublime. The same issue affects built in JSX syntax and babel-sublime.

Thom1729 commented 3 years ago

Looks like that was broken by a patch to jsx_close_tag that was written to accommodate a scope change in the core JSX syntax. I've written another patch that should fix the fix. It should be out in the next 4.1 beta. One of these days I need to write a test suite for the jsx_close_tag, and/or rewrite the command.

Thom1729 commented 2 years ago

I checked, and this is definitely working as of 4.2.0.