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

Repositions cursor at bottom of file on untabify #41

Closed
robhicks opened this issue Jan 21, 2016 · 10 comments
Closed

Repositions cursor at bottom of file on untabify #41

robhicks opened this issue Jan 21, 2016 · 10 comments
Labels

Comments

@robhicks
Copy link

Every time I untabify, the cursor is repositioned at the bottom of the file. Is there a way configure the package to leave the cursor at its current position?

@lee-dohm
Copy link
Owner

I'll take a look at this later today.

@lee-dohm
Copy link
Owner

Sorry it has taken me so long to get back to this. I can't reproduce this using Atom v1.4.1 on Mac OS X 10.11.3 with the latest version of tabs-to-spaces. Could you give the following information?

  • Which version of Atom are you using?
  • What OS and version are you running?
  • Is it certain file types that this happens in?
  • What other packages do you have installed?

@robhicks
Copy link
Author

@lee-dohm I recently updated to Atom v1.4.1 on OSX 10.11.3. Prior to the update, it was happening on all files. Unfortunately, before updating to Atom v1.4.1, I also tweaked some of my settings which resulted in Atom not inserting tabs instead of spaces so I can't reproduce the problem.

@lee-dohm
Copy link
Owner

I'm glad it is working for you now. I'll see if I can find the time to poke around and reproduce the problem. Thanks for reporting it!

@robhicks
Copy link
Author

@lee-dohm I figured out how to reproduce this.

If you use atom beautify on a fle, it changes spaces to tabs but leaves the cursor where it was before running it. Then when untabify is run on the file, it changes the tabs to spaces and the cursor is reposition ed at the end of the file.

@robhicks robhicks reopened this Jan 31, 2016
@lee-dohm
Copy link
Owner

I think you're going to need to be a little more specific. I installed atom-beautify and ran it on a random JS file and couldn't replicate what you're describing using Atom v1.6.0-dev-52c9067 on Mac OS X 10.11.3. Could you give the following information?

  • What language is the file you reproduced the issue in?
  • Do you have any specific beautify configuration?
  • Why do you have beautify change spaces to tabs only to change them back again? 😉

@robhicks
Copy link
Author

robhicks commented Feb 1, 2016

It happens for all the file types I have tried. I see it mostly with JavaScript files because I spend more time in them.

I have had the default configuration of Atom Beautify. I have used it mostly to reformat code that get's pasted in incorrectly.

Your question about why I have Atom Beautify change the indents to tabs and then untabify them was a good one. I have now modified by Atom Beautify settings to use tabs.

I am using Atom 1.4.1 on Mac OSX 10.11.13. I have the following packages installed:

├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

@lee-dohm
Copy link
Owner

lee-dohm commented Feb 1, 2016

I was able to reproduce this with both atom-beautify set to use tabs with JS and simply using tabify and then untabify on Atom v1.4.1 on Mac OS X 10.11.3. I'll work on it this week.

@lee-dohm
Copy link
Owner

Sorry this has gone so long without updates. I tracked down the regression to 4de9105. The performance optimization I added to resolve #16 prevents accurately retaining cursor positions. Because it replaces all text in the file whenever anything is changed, all cursors are pushed to the end.

In a tradeoff between correctness and performance, my personal opinion is to err on the side of correctness. I'll be reverting the performance optimization ... but hoping that I can retain it as an option in a future version in case people don't care where their cursors end up so long as it is fast 😀

lee-dohm added a commit that referenced this issue Feb 16, 2016
@lee-dohm
Copy link
Owner

Fixed in da929bf

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

No branches or pull requests

2 participants