You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Auto indent not correct when moving lines up or down #10524
When you move a group of selected lines up or down, Atom auto indents them to where it thinks they should fit in the code and it is not always correct. It should have the option to disable this flavor of auto indent.
Reacted by Hernán Schmidt, Ed Hinchliffe, Marcel Robitaille, Andrew, Brandon Ramirez, windkomo, Mark E. Haase, Genevieve, Piotr Migdał, Chris Martin and 13 more
If you go into Settings View and scroll down to Editor Settings, we do have an option to turn off Auto Indent and Auto Indent on Paste. Let us know if that solves your problem. 😬 crosses fingers
Reacted by Kieran Milligan
Reacted by Ashton, A. Mezine, Isaac Gregson, Alvaro and Thomas E. Jensen
Thanks for responding, that was quick! So I tried those settings earlier
and they don't affect the auto indent reformatting when using the hotkeys
(Ctrl + Option + up/down). Even with those two options turned off it still
will reformat indentation and not always for the better. It's particularly
noticeable when you highlight a block of code that has specific indentation
and move it up or down. I love Atom and this is my only issue with it.
Thanks for your help!
"A journey of a thousand miles begins with a single step."
On Jan 25, 2016 2:02 PM, "Amy Truong" [email protected] wrote:
If you go into Settings View and scroll down to Editor Settings, we do
have an option to turn off Auto Indent and Auto Indent on Paste. Let us
know if that solves your problem. [image: 😬] crosses fingers
—
Reply to this email directly or view it on GitHub #10524 (comment).
Thanks for reaching out- I just responded to Amy but here's some more
details that will hopefully help to reproduce the bug. I am on a Mac
(running El Capitan) and running Atom v1.4.0. I am code in CoffeeScript,
which uses indentation vs punctuation to define blocks of code (like
Python). The bug occurs when using the hotkeys to move selections up or
down (Ctrl + Command + up/down-arrow). It is particularly noticeable when
you highlight a chunk of code >5 lines which has specific indentation, and
move it up or down through other sections of code. Hope this helps and
please let me know if I can do more to help, thanks!
"If there's one attribute that everyone could adopt from the skateboarding
community, it's to have a desire to learn something new- to try, and fall,
and get up again- and repeat that process a thousand times until you
eventually get it right."
I tried switching off Auto Indent. That did the job, but it also turned off indenting every new line. The latter is a super useful feature – I can’t imagine coding without that.
I tried switching off Auto Indent on Paste. Unfortunately, that didn’t work.
I have also just had the same python issue. This really should be an option, and probably be off by default, at least for languages which have significant whitespace. There is further discussion of this issue on the original PR (#9104), with a custom command that solves it for me.
Reacted by Guillaume, Joe Lutz, Tomek Wiszniewski, Marius Millea, Philipp Weidenhiller, Sage Fennel Mock and Mark E. Haase
I'm finding this feature addition is almost always actually a hindrance to me. When I move code, it is extremely important it stays as it is (especially in Python, where indentation affects everything). After moving blocks of code it takes me a while to check if anything has changed, and to correct the indentation, where as a simple tab (or shift tab) would normally fix things after a move.
But I do appreciate the effort in trying to add a new feature, and I think it could be useful, but only (in my personal opinion) if no indentation changes within the selected lines
i.e. If the selected (multi-line) code is auto-indented less/more, indent it all equally (not just some lines of it).
Reacted by Tomek Wiszniewski, Hernán Schmidt, Kirill Korniakov, Andrew, Marius Millea, Ashton, Sage Fennel Mock, Mark E. Haase, Alejandro Avilés, NVS Abhilash and 1 more
Notice the one space added indentation, and what's even stranger, the added space actually gets selected.
Presumably to do with the fact that the comment block has a one-space "indentation". In this case the space is not really an indentation though, and the editor should "know" that my indentation is actually set to two spaces, not one, so it shouldn't interpret the single space as an indentation.
Demo:
This is with Atom 1.10.0-dev-e5a3c9e, and this joins several other comment block/indentation related issues like:
@benogle does this issue still require more information or do you have enough to start looking into it? I think it's probably a good idea if all of these related issues were tackled at the same time. It seems they are all at least somewhat related.
Let me know if you need more information or if you require me to do some testing.
I am using YAML and I have this problem. It works as I would like it when Auto Indent is false in Editor Setting, but I would much prefer to keep that setting turned on.
It would make a huge difference to me if there was a setting to turn this behaviour off!
Atom team: Why use auto-indent after the move? Auto-indent is always error prone in every editor.
Just store all the selected characters (like whitespace) in tmp memory.
If their is no selection, just store the entire line in tmp memory.
What's the technical hold up on this?
For posterity, this has been a really annoying problem with Atom since Atom was made. Tons of issues. Some PRs that don't actually fix the problem. etc.
Reacted by Isaac Gregson, Maximilian Knespel and Cornelius Dol
Well, any other editor I have seen so far (that supports moving of lines) handles that well. Only Atom tries to auto-indent during a move. So that's just unexpected behavior.
Moving that way makes it easier visible in my opinion. You move something until it fits perfectly. You do not have to trim or add empty lines before or after a block. It's WYSIWYG.
But if it's terribly hard to disable auto-indent while moving lines then perhaps it's really not worth fixing it.
Dear Atom developers: I believe you can fix this unexpected behavior deleting the following line from the definition of movelineup and movelinedown in TextEditor.js if (this.shouldAutoIndent()) this.autoIndentSelectedRows()
Please try to fix this, as I find this issue to be a huge problem when I'm using Atom to write most kinds of code.
I've used Atom for a couple months and while the overall layout and feel is very nice (the Git integration is especially lovely), this issue with auto-indentation has already caused frustrating bugs in my code on three separate occasions (all in Python). Two of those bugs were caused by the addition of single spaces in large blocks of code (as described by @adamreisnz), which is very difficult to spot visually.
While I hugely appreciate that Atom is open source, I'll be going back to Sublime after this on account of text movement being a stable operation there :(
This issue has been automatically marked as stale because it has not had recent activity. Because the Atom team treats their issues as their backlog, stale issues are closed. If you would like this issue to remain open:
Verify that you can still reproduce the issue in the latest version of Atom
Comment that the issue is still reproducible and include:
What version of Atom you reproduced the issue on
What OS and version you reproduced the issue on
What steps you followed to reproduce the issue
Issues that are labeled as triaged will not be automatically marked as stale.
Yes, I can still reproduce in the latest version (1.16.0), and it's INCREDIBLY annoying. It also, badly auto-indents when I edit an existing line, behavior which drives me completely bonkers.
What I would really like is the option to auto-indent to current indentation level on insertion of a new line ONLY. Just that. Nothing else. Nothing fancy. Just maintain the current indentation upon line insertion. While I know I can turn off indentation altogether, the indentation on insertion of a new line is incredibly useful. Essentially, you've borked the most useful auto-indent behavior by trying to make it too fancy.
Activity
amytruong commentedon Jan 25, 2016
If you go into Settings View and scroll down to Editor Settings, we do have an option to turn off Auto Indent and Auto Indent on Paste. Let us know if that solves your problem. 😬 crosses fingers
benogle commentedon Jan 25, 2016
Also, can you be more specific about your atom version and what languages you're having problems with?
brandonk3nt commentedon Jan 25, 2016
Hey Amy,
Thanks for responding, that was quick! So I tried those settings earlier
and they don't affect the auto indent reformatting when using the hotkeys
(Ctrl + Option + up/down). Even with those two options turned off it still
will reformat indentation and not always for the better. It's particularly
noticeable when you highlight a block of code that has specific indentation
and move it up or down. I love Atom and this is my only issue with it.
Thanks for your help!
Brandon Kent | Software Engineer
www.brandonk3nt.com
Email: [email protected]
Cell: 480.788.1301
"A journey of a thousand miles begins with a single step."
On Jan 25, 2016 2:02 PM, "Amy Truong" [email protected] wrote:
brandonk3nt commentedon Jan 25, 2016
Hey Ben,
Thanks for reaching out- I just responded to Amy but here's some more
details that will hopefully help to reproduce the bug. I am on a Mac
(running El Capitan) and running Atom v1.4.0. I am code in CoffeeScript,
which uses indentation vs punctuation to define blocks of code (like
Python). The bug occurs when using the hotkeys to move selections up or
down (Ctrl + Command + up/down-arrow). It is particularly noticeable when
you highlight a chunk of code >5 lines which has specific indentation, and
move it up or down through other sections of code. Hope this helps and
please let me know if I can do more to help, thanks!
Brandon Kent | Software Engineer
E: [email protected] [email protected]
T: 480.788.1301
brandonk3nt.com http://www.brandonk3nt.com/
"If there's one attribute that everyone could adopt from the skateboarding
community, it's to have a desire to learn something new- to try, and fall,
and get up again- and repeat that process a thousand times until you
eventually get it right."
On Mon, Jan 25, 2016 at 2:09 PM, Ben Ogle [email protected] wrote:
benogle commentedon Jan 25, 2016
Noted, yeah, it's really bad at auto indenting chunks for whitespace delimited languages.
tomek-he-him commentedon Feb 15, 2016
Hi, I’m also having trouble with this feature when coding in Elm – another language with significant whitespace.
As @amytruong suggested:
maackle commentedon Feb 17, 2016
I just ran into this problem too. Here's a simple case in Python:
If I highlight lines 2-4 and move them up or down,
print("buzz")gets indented to the same level asprint("fizz"), totally changing the program.radiac commentedon Feb 29, 2016
I have also just had the same python issue. This really should be an option, and probably be off by default, at least for languages which have significant whitespace. There is further discussion of this issue on the original PR (#9104), with a custom command that solves it for me.
code-tree commentedon Mar 1, 2016
I'm finding this feature addition is almost always actually a hindrance to me. When I move code, it is extremely important it stays as it is (especially in Python, where indentation affects everything). After moving blocks of code it takes me a while to check if anything has changed, and to correct the indentation, where as a simple tab (or shift tab) would normally fix things after a move.
But I do appreciate the effort in trying to add a new feature, and I think it could be useful, but only (in my personal opinion) if no indentation changes within the selected lines
i.e. If the selected (multi-line) code is auto-indented less/more, indent it all equally (not just some lines of it).
mgruner commentedon Apr 12, 2016
+1
Krknv commentedon May 30, 2016
Just used Ctrl+Command+up/down and cmd + z
mxmlnkn commentedon Jun 7, 2016
@RsD0p9BK Doesn't work for me, also not very high usability.
As for reproduction:
I have the following plain text (!)
test.txtWhen trying to move the line with
thereup using Ctrl+Up the indentation gets lost resulting inUsing Atom 1.8.0 on Debian.
Krknv commentedon Jun 8, 2016
@mxmlnkn Try to add empty string at the end of file
(Eight on my picture)adamreisnz commentedon Jun 26, 2016
Here's another way to reproduce weird indentation behaviour when moving lines of code up:
Notice the one space added indentation, and what's even stranger, the added space actually gets selected.
Presumably to do with the fact that the comment block has a one-space "indentation". In this case the space is not really an indentation though, and the editor should "know" that my indentation is actually set to two spaces, not one, so it shouldn't interpret the single space as an indentation.
Demo:
This is with Atom 1.10.0-dev-e5a3c9e, and this joins several other comment block/indentation related issues like:
#11995
#5362
#7256 (comment)
@benogle does this issue still require more information or do you have enough to start looking into it? I think it's probably a good idea if all of these related issues were tackled at the same time. It seems they are all at least somewhat related.
Let me know if you need more information or if you require me to do some testing.
5 remaining items
chris-martin commentedon Feb 3, 2017
The relevant functions are here:
atom/src/text-editor.coffee
Line 1113 in 1a039df
Could we work around this with a plugin to add alternative versions of those functions?
adamreisnz commentedon Feb 3, 2017
If it were written in normal javascript/ES6+ I'd happily take a look, but alas, I'm allergic to Coffeescript ;)
LydiaF commentedon Apr 26, 2017
Hi there,
I am using YAML and I have this problem. It works as I would like it when Auto Indent is false in Editor Setting, but I would much prefer to keep that setting turned on.
It would make a huge difference to me if there was a setting to turn this behaviour off!
Thank you :)
oneschilling commentedon Aug 21, 2017
I am having the same issue. An option to turn auto indentation off for moving lines up and down would be great.
corysimmons commentedon Sep 21, 2017
Atom team: Why use auto-indent after the move? Auto-indent is always error prone in every editor.
What's the technical hold up on this?
For posterity, this has been a really annoying problem with Atom since Atom was made. Tons of issues. Some PRs that don't actually fix the problem. etc.
Signum commentedon Sep 21, 2017
Well, any other editor I have seen so far (that supports moving of lines) handles that well. Only Atom tries to auto-indent during a move. So that's just unexpected behavior.
Moving that way makes it easier visible in my opinion. You move something until it fits perfectly. You do not have to trim or add empty lines before or after a block. It's WYSIWYG.
But if it's terribly hard to disable auto-indent while moving lines then perhaps it's really not worth fixing it.
DiThi commentedon Nov 23, 2017
It's ironic that it's written in Coffee Script. It destroys the indentation on Coffee Script!!
I'm OK with it moving the whole block left or right. But moving individual lines of code makes it USELESS for most cases.
Extremely simple case:
turns into
And the worst part is that sometimes it happened to us without noticing, introducing bugs.
gardwired commentedon Mar 12, 2018
please fix. autoindent shouldn't pertain to moves.
critcha commentedon Jan 5, 2019
Dear Atom developers: I believe you can fix this unexpected behavior deleting the following line from the definition of movelineup and movelinedown in TextEditor.js
if (this.shouldAutoIndent()) this.autoIndentSelectedRows()Please try to fix this, as I find this issue to be a huge problem when I'm using Atom to write most kinds of code.
jemisjoky commentedon Apr 1, 2019
I've used Atom for a couple months and while the overall layout and feel is very nice (the Git integration is especially lovely), this issue with auto-indentation has already caused frustrating bugs in my code on three separate occasions (all in Python). Two of those bugs were caused by the addition of single spaces in large blocks of code (as described by @adamreisnz), which is very difficult to spot visually.
While I hugely appreciate that Atom is open source, I'll be going back to Sublime after this on account of text movement being a stable operation there :(
stale commentedon Mar 31, 2020
Thanks for your contribution!
This issue has been automatically marked as stale because it has not had recent activity. Because the Atom team treats their issues as their backlog, stale issues are closed. If you would like this issue to remain open:
Issues that are labeled as triaged will not be automatically marked as stale.
cornelius-dol commentedon Sep 24, 2022
Yes, I can still reproduce in the latest version (1.16.0), and it's INCREDIBLY annoying. It also, badly auto-indents when I edit an existing line, behavior which drives me completely bonkers.
What I would really like is the option to auto-indent to current indentation level on insertion of a new line ONLY. Just that. Nothing else. Nothing fancy. Just maintain the current indentation upon line insertion. While I know I can turn off indentation altogether, the indentation on insertion of a new line is incredibly useful. Essentially, you've borked the most useful auto-indent behavior by trying to make it too fancy.