Comments (5)
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.
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.
I only found a couple instances of this, so I'm in no big trouble at the moment 👍
from stylua.
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.
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)
- [Feat Request] Add `web` target for wasm build HOT 1
- stylua fails to format 1 line range HOT 2
- Add a function to set config on wasm version HOT 1
- `GLIBC_2.28` not found on Ubuntu 18.04 HOT 4
- pre-commit setup failure: KeyError: 'git-url' HOT 2
- Tests fail on v0.19.0, stack overflow in test_large_example HOT 8
- Modification time of unchanged files are changed HOT 1
- Luau: stylua erroneously removes parentheses around string union table indexers
- feature request: regarding support for "func {foo=.., bar=..}" named args syntax HOT 2
- Function definition for a very long variable name results into only closing bracket moved to the next line HOT 1
- feat: Use closest `stylua.toml` config to file being formatted HOT 7
- Add option to add spaces in function definitions HOT 2
- Ignore VCS ignored files HOT 1
- Is it possible to allow inline functions? HOT 4
- `--respect-ignores`: does not correctly ignore folders without the globbing pattern HOT 2
- Stylua extension won't format files HOT 4
- 1.6.0 doesn't seem to be supporting my Lua files HOT 8
- Stylua doesn't enforce column_width correctly with some inputs HOT 2
- feat: Support LuaCATS comment formatting HOT 2
- Question- Support ? and ` characters? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stylua.