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

not formatting correctly when line is too long #62

Closed
lgrandco opened this issue Aug 31, 2023 · 11 comments · Fixed by #63
Closed

not formatting correctly when line is too long #62

lgrandco opened this issue Aug 31, 2023 · 11 comments · Fixed by #63

Comments

@lgrandco
Copy link
Contributor

lgrandco commented Aug 31, 2023

when we continue the previous line on a new line, we need to indent twice instead of once, but it re formats to only one tab so we need to save without formatting.
wrong (just formatted):
image
correct:
image

@younesaassila
Copy link
Contributor

Encountered the bug recently too and have just pushed a fix to my fork. Will soon open a PR here

@cacharle
Copy link
Collaborator

(please don't send code as screenshot 😢 , just the the triple back quote)

This is probably made by the line_breaker formatter of @keyhr.

@younesaassila
Copy link
Contributor

This is caused by some weird Norminette exception that variable assignments have one additional indent when nesting occurs. Don't ask me the reasoning behind this.....

@lgrandco
Copy link
Contributor Author

sorry for the screenshot, I just saw this issue #50, so it seems that both assigning and calling a function add an indent level, that's why it needed one more here

@lgrandco
Copy link
Contributor Author

so

		ft_fprintf(2, "\r%d/%d %ld %ld", i + 1, g->w.y, (t_u64)m,
			(t_u64)g->b.z);

and

			z = (t_v2d){g->b.rs + ((t_f64)j / g->w.x) * (g->b.re - g->b.rs),
				g->b.is + ((t_f64)i / g->w.y) * (g->b.ie - g->b.is)};

are now correctly formated, but

			z = ft_fprintf(2, "\r%d/%d %ld %ld", i + 1, g->w.y, (t_u64)m,
				(t_u64)g->b.z);;

should be

			z = ft_fprintf(2, "\r%d/%d %ld %ld", i + 1, g->w.y, (t_u64)m,
					(t_u64)g->b.z);;

@younesaassila younesaassila mentioned this issue Aug 31, 2023
@cacharle
Copy link
Collaborator

@lgrandco can you clone the branch from #63 and test it on your local machine to make sure this is actually fixed?

@lgrandco
Copy link
Contributor Author

it fixed

			z = ft_fprintf(2, "\r%d/%d %ld %ld", i + 1, g->w.y, (t_u64)m,
					(t_u64)g->b.z);;

(correct)

but does not work for

			t_z.z = ft_fprintf(2, "\r%d/%d %ld %ld", i + 1, g->w.y, (t_u64)m,
				(t_u64)g->b.z);;

(same with)

t_z->z

@younesaassila
Copy link
Contributor

younesaassila commented Aug 31, 2023

Ah I see. The problem is it only matches {name} = ... but the regex doesn't match dot notation or arrow notation. No idea if there's even such a regex helper for that in the code already?

@younesaassila
Copy link
Contributor

younesaassila commented Aug 31, 2023

I mean perhaps I could change it to ... = ... (basically any line with an equal sign) but not sure if it's a good idea 🤔

@younesaassila
Copy link
Contributor

Alright fixed now with a tweaked regex r"^\s*({decl})((\.|->){decl})*\s+=\s+[^;]*?;$"

@lgrandco
Copy link
Contributor Author

everything seems good, thanks 👍

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

Successfully merging a pull request may close this issue.

3 participants