Code Monkey home page Code Monkey logo

Comments (9)

ahuth avatar ahuth commented on September 27, 2024

@FezVrasta Thanks for your kind words and feedback. Also, sorry it took me so long to comment on this. I really need to figure out how to get notified when someone opens up an issue on one of my repositories.

To be honest, I'm not really sure how to fix this. The extension is really simple and works be looping over every line in the file and telling CodeMirror (which Brackets uses as the actual editor) to re-indent the line.

Because of this, the problem is I don't actually tell CodeMirror how to indent. That part is magic as far as the extension is concerned.

I'll research other means of indenting the document, though. Know of any good, open-source, Javascript parsers written in Javascript?

from brackets-indentator.

ahuth avatar ahuth commented on September 27, 2024

@FezVrasta Also, why does the .remove() call get indented another level from everything else?

I haven't used jQuery extensively, but it seems like all of the chained function calls would be at the same level.

from brackets-indentator.

FezVrasta avatar FezVrasta commented on September 27, 2024

It's the syntax of jQuery, each time you select a different element you indent one tab. When you go back to the previous you remove one indent

from brackets-indentator.

FezVrasta avatar FezVrasta commented on September 27, 2024
$("<a/>") // <a/> is selected so indent the next command
    .append("<span/>") // one element is appended to <a/> but we keep staying on <a/>
    .find("span") // we move to the <span/> element so we indent the next command
        .remove() // we remove the <span/> element but we are not leaving this element
    .end() // we go back to the <a/> element so we remove one indentation
    .remove(); // we remove the <a/> element so we stay on the same line.

from brackets-indentator.

ahuth avatar ahuth commented on September 27, 2024

Gotcha. I don't think I can get the syntax you want, because I don't want to put in a bunch of logic that is specific to jQuery.

I do agree, though, that all of the function calls should at least have one more level of indentation than the $("<a/>").

That would end up looking like this:

$("<a/>")
    .append("<span/>")
    .find("span")
    .remove()
    .end()
    .remove();

As I said before, I'm not really sure how to fix this. I'm thinking we'll have to come up with a different way to indent the source than it does currently. I'm definitely open to suggestions on how to tackle this.

from brackets-indentator.

FezVrasta avatar FezVrasta commented on September 27, 2024

Just find the /(jQuery|$)(*.)/ regex (not tested) should be enough

from brackets-indentator.

ahuth avatar ahuth commented on September 27, 2024

It looks like this is a problem with text-editors in general. Codemirror doesn't recognize that the .whatever() calls should be indented. The same thing happens in SublimeText 3.

If I type $("</a>") into Brackets (or SublimeText) and hit enter, the next line is not indented another level. So if the editor doesn't recognize that subsequent lines should be indented, this extension won't be able to indent it that way, either.

The extension should indent code in exactly the same way the editor would in the first place, so we can't change how jQuery functions are indented.

I won't be able to fix this. Sorry.

from brackets-indentator.

FezVrasta avatar FezVrasta commented on September 27, 2024

adobe/brackets#7672

from brackets-indentator.

tomek-he-him avatar tomek-he-him commented on September 27, 2024

AngularJS proposes a coding style which could possibly be easier to implement. How about that?

$someModule.
    doStuff().
    doMoreStuff();

from brackets-indentator.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.