Giter Site home page Giter Site logo

Comments (5)

JohnnyMorganz avatar JohnnyMorganz commented on May 27, 2024 4

Thanks, I think that's a separate case handled differently inside the codebase (with the same problem) so I'll also need to check that out.

Sorry, I've been bombarded with work recently so I'll see when I can make time to fix this bug

from stylua.

JohnnyMorganz avatar JohnnyMorganz commented on May 27, 2024

This is an interesting problem. I'm going to need to create some sort of buffer for any comments within expressions, and then push them towards the end of the line where its "safe" to place them.

Is this a common occurrence in your codebase? I'm currently busy with some other work at the moment but I can take a look at this soon - from first glance, it does look like I'll need to think some more about how to solve this.

from stylua.

NPhrd avatar NPhrd commented on May 27, 2024

I only found a couple instances of this, so I'm in no big trouble at the moment 👍

from stylua.

NPhrd avatar NPhrd commented on May 27, 2024

Depending on your solution, this probably won't be a separate issue, but I'll mention it just in case

Before running StyLua:

print"text" --a comment

After running StyLua:

print("text" --a comment)

from stylua.

JohnnyMorganz avatar JohnnyMorganz commented on May 27, 2024

a0f6bdd is a partial fix for this, mainly the situations where there are comments present inside of function arguments, and comments trailing commas in punctuated sequences. Function calls will now remain expanded if there is a comment present inside of them, to keep the comments as close as possible to original code. Currently, in other cases where comments are in weird locations, I'm buffering them to the end of the line. This does mean that they may move from where people originally wanted them to be, and if that is a problem, please do let me know!

I still need to figure out a way to handle comments within expression properly (the example you gave above with the summation of the numbers). I think I need to do something similar as with function call arguments, where I just leave them wrapped onto multiple lines - but currently StyLua doesn't support multiline expressions anyways. This will probably have to wait until a change to support #25 is added

from stylua.

Related Issues (20)

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.