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

toggle_multiline() breaks casting in Rust #41

Open
Ciel-MC opened this issue May 6, 2023 · 6 comments · May be fixed by #42
Open

toggle_multiline() breaks casting in Rust #41

Ciel-MC opened this issue May 6, 2023 · 6 comments · May be fixed by #42

Comments

@Ciel-MC
Copy link

Ciel-MC commented May 6, 2023

Before:
image
After:
image

@Ciel-MC
Copy link
Author

Ciel-MC commented May 6, 2023

Notably, https://github.com/Wansmer/treesj/ handles it fine.
image

@CKolkey
Copy link
Owner

CKolkey commented May 6, 2023

Could you post the correct before/after (and maybe a couple other test cases) so I can build a spec? I don't actually use rust :)

@Ciel-MC
Copy link
Author

Ciel-MC commented May 6, 2023

Could you post the correct before/after (and maybe a couple other test cases) so I can build a spec? I don't actually use rust :)

Hey, I have mentioned the correct way it should be formatted in my previous comment, but I'll try and find more examples tomorrow.

alexpw added a commit to alexpw/ts-node-action that referenced this issue May 8, 2023
@alexpw alexpw linked a pull request May 8, 2023 that will close this issue
@Ciel-MC
Copy link
Author

Ciel-MC commented May 8, 2023

Found another issue, something like

fn test() {
    let foo = stuff();
}```
gets collapsed into
```rust
fn test() { letfoo = stuff(); }

it is mostly right, but let variable and let mut variable gets collapsed into letvariable and letmutvarialble respectively, which, yk, isn't good.

Before:
image
Actual:
image
Expect:
image

@Ciel-MC
Copy link
Author

Ciel-MC commented May 8, 2023

Found another issue, something like

fn test() {
    let foo = stuff();
}```
gets collapsed into
```rust
fn test() { letfoo = stuff(); }

it is mostly right, but let variable and let mut variable gets collapsed into letvariable and letmutvarialble respectively, which, yk, isn't good.

Before: image Actual: image Expect: image

In addition, mutable borrows are also incorrectly collapsed, &mut buf -> &mutbuf, both as a type in function signatures fn test(foo: &mut Foo) and as a value value.serialize(&mut serializer)

The common part of all the problems seems to be that tokens separated by whitespaces are merged together, maybe some sort of system needs to be in place to ensure that certain tokens are separated by whitespaces after collapsing. Again mentioning treesj, all the above situations are handled by treesj just fine, just mentioning it because it might help as a reference.

alexpw added a commit to alexpw/ts-node-action that referenced this issue May 8, 2023
@alexpw
Copy link
Contributor

alexpw commented May 8, 2023

@Ciel-MC thank you for the examples. I've fixed all that were mentioned, if you'd like to try that branch and confirm (#42). Please keep 'em coming, if you find more cases.

bo5o pushed a commit to bo5o/ts-node-action that referenced this issue Jul 29, 2023
bo5o pushed a commit to bo5o/ts-node-action that referenced this issue Jul 29, 2023
bo5o pushed a commit to bo5o/ts-node-action that referenced this issue Jul 31, 2023
bo5o pushed a commit to bo5o/ts-node-action that referenced this issue Jul 31, 2023
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