Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't shift one-line functions #38

Closed
MAGNAT2645 opened this issue Jan 13, 2019 · 6 comments
Closed

Don't shift one-line functions #38

MAGNAT2645 opened this issue Jan 13, 2019 · 6 comments

Comments

@MAGNAT2645
Copy link

Autoformat always shifts one-line ( without { } ) functions (and not only functions, can be also inside loops). Would be better if autoformat will not touch it.
eb

And some from GitHub:
eb

@Timocop
Copy link
Owner

Timocop commented Jan 13, 2019

I think leaving lines out will confuse users more than wrong indention. Currently, reidention is pretty basic (Just like Notepad++) and has some non-context aware checks. I will improve it in the future however.

For now if your source is complex (like the screenshots you posted) just format code at selected lines instead of the whole project.

@Timocop
Copy link
Owner

Timocop commented Jan 15, 2019

Single-line function reindentions are intentional. However there was an issue escaped-newlines on preprocessor directives (\\n). Fixed that. Preprocessor directives should now reindented correctly.
I also removed reindention after statements. Always behaved quite dumb since it only checked one line (like your example in the picture at the bottom). eg formating:

if(a)
    if(b)
        if(c)
        {
            c = 0;
        }

will result in:

if(a)         //Indention = Scope-depth
    if(b)     //Indention = Scope-depth + if^
    if(c)     //Indention = Scope-depth + if^
{
    c = 0;
}

and now it results in:

if(a)
if(b)
if(c)
{
    c = 0;
}

just like Notepad++.

@Timocop Timocop closed this as completed Jan 15, 2019
@MAGNAT2645
Copy link
Author

Is that normal behavior to autoformat?

default

@Timocop
Copy link
Owner

Timocop commented Jan 29, 2019

Yes. I removed the after-statement shift. It was quite buggy if used with multiple statements, explained above. Now it works like Notepad++'s format code.

@MAGNAT2645
Copy link
Author

MAGNAT2645 commented Jan 29, 2019

It's good but I'm used to using such one-line algorithms without brackets as above. Is there any way to, like, "toggle" it back?

So now i have something like this
default

@Timocop
Copy link
Owner

Timocop commented Jan 31, 2019

I will bring it back eventualy. But im not using the old system for that nor do i bring the old thing back. But you can use an older BasicPawn version to still format your code like that. But youll have to wait a little while for the new system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants