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

When run rustic-cargo-build/run, if main.rs exist syntax error, cursor always skip to beginning of buffer. #172

Closed
zw963 opened this issue Oct 19, 2020 · 23 comments · Fixed by #191

Comments

@zw963
Copy link

zw963 commented Oct 19, 2020

Following is reproduce:

Current cursor in rs file on line 46.

M-x run rustic-cargo-build, then cursor switch to new open compilation buffer window.

M-x run quit-window

my cursor in rs file on line 1.

What i expected

When run quit-window, cursor should go back to original position, as it did for rustic-recompile.

thank you.

@zw963
Copy link
Author

zw963 commented Oct 20, 2020

Sorry, i found i can't reproduce this issue today, let me close it first, and enable if i can reproduce again.

Thank you.

@zw963 zw963 closed this as completed Oct 20, 2020
@zw963
Copy link
Author

zw963 commented Oct 20, 2020

I reproduce it again.

for reproduce reason, i upload my main.rs here.

https://raw.githubusercontent.com/zw963/zw963.github.io/master/files/main.rs

When my cursor is on line 36, then run rustic-cargo-run, cursor skip to beginning of buffer immediately.

thank you.

@zw963 zw963 reopened this Oct 20, 2020
@samhedin
Copy link
Collaborator

My cursor doesn't jump into the compile window at all, but that might be because of my setup. A question though - the code you posted does not compile, does working code or non-working code change the behavior?

@zw963
Copy link
Author

zw963 commented Oct 21, 2020

@samhedin , Yes, you are right, this issue only happen on some syntax error happen on main.rs,
because this, i upload my code here.

image

My cursor doesn't jump into the compile window at all,

Yes, if not jump into the compile window, the cursor should jump to beginning of buffer immediately.

@zw963 zw963 changed the title When run rustic-cargo-build/run, switch to compile buffer window, then press q, lose cursor position. When run rustic-cargo-build/run, if main.rs exist syntax error, cursor always skip to beginning of buffer. Oct 23, 2020
@brotzeit
Copy link
Owner

Sorry I can't reproduce this.

I place my cursor on line 36 in your code, run rustic-cargo-run, switch to compilation buffer and quit the compilation buffer.

I don't notice anything happening.

@zw963
Copy link
Author

zw963 commented Oct 23, 2020

@brotzeit , can you please try use following three 3 config to reproduce?

update lsp-mode, lsp-ui, rustic-mode, company-mode to use newest master.

Use only following config + emacs 27.1, i can always reproduce this issue.

rustic: http://dpaste.com/GR37X6948
lsp-mode: http://dpaste.com/FYSWWTJUE
company: http://dpaste.com/CWVW2AKAZ

BTW: in fact, cursor never will be skip to compilation buffer if not config to use
shackle package, it just skip cursor to beginning of buffer immediately when run
rustic-cargo-run as only above config.

@zw963
Copy link
Author

zw963 commented Oct 27, 2020

Any idea? i just want to know, if i describe my issue clearly in my previous comment. thank you.

@samhedin
Copy link
Collaborator

I sat down to take another look at this, but the pastes are gone. Could you re-upload them? :)

@zw963
Copy link
Author

zw963 commented Nov 12, 2020

Thank you. @samhedin

main.rs (You can see a syntax error on line 39:26, this is the prerequisite which cause this issue.)

https://raw.githubusercontent.com/zw963/zw963.github.io/master/files/main.rs

rustic config:
http://dpaste.com/AN3TVC74M

lsp-mode config:

http://dpaste.com/94XSKP4YE

company config (maybe not related, but anyway, provided it)
http://dpaste.com/AE77WEXEM

@zw963
Copy link
Author

zw963 commented Nov 14, 2020

@samhedin , any idea?

@samhedin
Copy link
Collaborator

Will try tomorrow!

@samhedin
Copy link
Collaborator

samhedin commented Nov 16, 2020

On a fresh emacs install with only lsp-mode and rustic installed, with this in init.el (the configs you sent for lsp-mode and rustic) https://pastebin.com/raw/gjVHQupE I get almost the same error as you are talking about. Running rustic-cargo-build does not switch the cursor to the *rustfmt* window, but it does send the cursor to the top of the document. I see how this is frustrating behavior, but can't commit to doing anything about it atm.

@samhedin samhedin added the bug label Nov 16, 2020
@zw963
Copy link
Author

zw963 commented Nov 16, 2020

On a fresh emacs install with only lsp-mode and rustic installed, with this in init.el (the configs you sent for lsp-mode and rustic) https://pastebin.com/raw/gjVHQupE I get almost the same error as you are talking about. Running rustic-cargo-build does not switch the cursor to the *rustfmt* window, but it does send the cursor to the top of the document. I see how this is frustrating behavior, but can't commit to doing anything about it atm.

Thank you for reproduce, @brotzeit , if you have time, please try it too, thank you.

@thor314
Copy link

thor314 commented Nov 18, 2020

Having same issue. On calling rustic-format-buffer (cargo-process-fmt, from rust mode does not reproduce this error) with a syntax error, cursor jumps to compilation buffer, and moves cursor in the rust file to somewhere near the top.

@brotzeit
Copy link
Owner

Is this also the case for rustic-format-file ?

@zw963
Copy link
Author

zw963 commented Nov 26, 2020

Is this also the case for rustic-format-file ?

I tested just now, it don't work too, but, rustic-format-file skip to another unexpected place instead of beginning of buffer.

@thor314
Copy link

thor314 commented Nov 26, 2020

@brotzeit - rustic-format-file reproduces the error, point jumps to other buffer, with the message <file>.rs changed on disk; really edit the buffer? (y...)

@zw963
Copy link
Author

zw963 commented Nov 27, 2020

@brotzeit , i tested, rust-format-buffer and rust-format-file seems like works, but when run rustic-cargo-run, still same(jump to beginning of buffer)

Thanks.

brotzeit added a commit that referenced this issue Nov 27, 2020
@brotzeit brotzeit reopened this Nov 27, 2020
@zw963
Copy link
Author

zw963 commented Dec 26, 2020

Hi, @brotzeit , i switched to use rust-mode + lsp, all features works quite well for now.

This issue can't be reproduce when use rust-mode instead of rustic-mode, so
this bug was not so necessory for me anyway if it hard to fix.

i will keep this issue open, if you done this, i will very happy for test it.

Thank you.

@thor314
Copy link

thor314 commented Dec 29, 2020

@zw963, I ultimately turned off rust(ic)?-format-on-save, which appears to have been my source of issue.

@zw963
Copy link
Author

zw963 commented Dec 30, 2020

@zw963, I ultimately turned off rust(ic)?-format-on-save, which appears to have been my source of issue.

I think i never enable this for my config since this issue was created, so, i don't think so.

@brotzeit
Copy link
Owner

brotzeit commented Jan 5, 2022

@zw963 ok I was finally able to reproduce this issue(no idea why it didn't work before).

It seems the issue is run-hook-with-args-until-failure in rustic-compilation-start. Not all cargo commands use this wrapper function. We have to call save-excursion.

Sorry that it took so long. Wasn't that hard to find out.

@zw963
Copy link
Author

zw963 commented Jan 9, 2022

I confirm today, it works for me now.

thank you very much!

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

Successfully merging a pull request may close this issue.

4 participants