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 on paste behaves oddly with already indented lines. #5473
When copying a segment of code that starts with a new-line followed by tabbed-in code while "Auto Indent On Paste" is enabled, consecutive pastes will each be an additional tab deeper. I tested this with C++, Java, and JavaScript which makes me believe it is not a problem with the language specs.
Here is an example in the form of an animated gif:
It isn't just comments that this happens with, but it does require the previous line to be selected. Specifically, this happens when the copy-buffer matches a regex like /^\n\s+[^\s]/. That is, it starts with a newline, followed by one or more whitespace characters and then a non-whitespace character. And the previous line must be a blank line.
Reacted by Greg Dehmlow, Wentao Liu, Daniel Darabos, err, Lars Schütze, Tyler Benster, Yusuf Sultan, Otto Seiskari, Mathias Panzenböck, Hugues Chabot and 3 more
Oops, should have included that. I'm using Mac 10.10.2 with Atom v0.177.0, but I've been experiencing this bug for a few versions now (not entirely sure when it first presented).
Interesting, just tried to reproduce this on my Windows build box too. It has v0.175.0 installed. On that machine the behavior is reversed. When Auto Indent On Paste is enabled then pasting behaves as expected (each consecutive line is pasted at the same depth). However when that option is disabled then the first paste behaves as expected, but the 2nd through nth pastes are all one level deeper than the last. Not sure how to update the Windows version to see if it persists in 0.177.0.
@NatalieWolfe I'm having trouble reproducing this in the latest version of Atom:
$ atom -v
0.180.0-2dac7fd
Here's what I'm doing:
Is there something I'm doing differently than you are?
Can you try reproducing this again and record a gif in which the invisible characters are shown as well as the keybinding resolver (cmd+.)? Also, can you record the gif so that includes the point at which you select and copy text into the clipboard for the first time (it's not shown in the gif above)?
Atom should update to the latest version on its own, but you can download the latest version here as well:
I notice on your gif, @izuzak, that you are using a plain text file. I don't think Auto Indent on Paste works in plaintext files (there is no structure to the text for it to use).
I notice on your gif, @izuzak, that you are using a plain text file. I don't think Auto Indent on Paste works in plaintext files (there is no structure to the text for it to use).
Ahhhh, that was it, thanks @NatalieWolfe! Seeing it now as well.
...Oh I see what's going on here. Let me follow up on my last comment.
Auto Indent On Paste is trying to auto-indent the block as a whole, based on first line's indentation:
Whereas PHPStorm is also fixing indentation within the block, making sure each line auto-indents correctly:
IMHO, maybe there should be more consistency between manually running Auto Indent, and Auto Indent On Paste, since running Auto Indent manually is smart enough to fix the mess.
@patstew Awesome, this has been bugging me for a while. I did notice one unexpected thing. When pasting over the existing block it removes the indent when it shouldn't. Not that this is a particularly realistic use case (why would you paste over a block with the same content). Just thought you might like to know. See screenshots (first is copy, second is paste).
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.
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.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
Activity
winstliu commentedon Feb 10, 2015
What version of Atom is this on?
/cc @maxbrunsfeld
NatalieWolfe commentedon Feb 10, 2015
Oops, should have included that. I'm using Mac 10.10.2 with Atom v0.177.0, but I've been experiencing this bug for a few versions now (not entirely sure when it first presented).
Interesting, just tried to reproduce this on my Windows build box too. It has v0.175.0 installed. On that machine the behavior is reversed. When Auto Indent On Paste is enabled then pasting behaves as expected (each consecutive line is pasted at the same depth). However when that option is disabled then the first paste behaves as expected, but the 2nd through nth pastes are all one level deeper than the last. Not sure how to update the Windows version to see if it persists in 0.177.0.
izuzak commentedon Feb 13, 2015
@NatalieWolfe I'm having trouble reproducing this in the latest version of Atom:
Here's what I'm doing:
Is there something I'm doing differently than you are?
Can you try reproducing this again and record a gif in which the invisible characters are shown as well as the keybinding resolver (
cmd+.)? Also, can you record the gif so that includes the point at which you select and copy text into the clipboard for the first time (it's not shown in the gif above)?Atom should update to the latest version on its own, but you can download the latest version here as well:
https://github.com/atom/atom/releases/latest
NatalieWolfe commentedon Feb 13, 2015
@izuzak: The link you provided goes to 0.179.0, which is what I have installed on my Mac at the moment.
Here is an updated gif, starting from a completely new window. Auto Indent on Paste is enabled during this demonstration.
If you would like me to make another where I type slower (so you have more time to see the keybinding resolver updates) let me know.
NatalieWolfe commentedon Feb 13, 2015
I notice on your gif, @izuzak, that you are using a plain text file. I don't think Auto Indent on Paste works in plaintext files (there is no structure to the text for it to use).
izuzak commentedon Feb 13, 2015
Ahhhh, that was it, thanks @NatalieWolfe! Seeing it now as well.
karai17 commentedon Apr 30, 2015
I am running the current Atom (194) on Windows 7 and this issue persists.
muppetjones commentedon May 19, 2015
There are many indentation problems, and I'm trying to link all of them together in a single issue: here
jesseleite commentedon Sep 1, 2015
I'm finding that
Auto Indentworks differently thanAuto Indent On Pastesetting in Atom. There's a consistency issue between the two...If I take this PHP method:
And paste it into a PHP class, I get:
So
Auto Indent On Pasteis doing something, but it's not doing it correctly. However, if I now runAuto Indentfrom the Edit > Lines menu, I get this:Beautiful, now it's properly intended for my PHP class. Auto indentation on paste is something PHPStorm does without flaw (see http://g.recordit.co/Rj6unPomlW.gif). It's weird that Atom can manually
Auto Indentfine, butAuto Indent On Pasteseems useless sometimes.(For the record, I'm on Yosemite with Atom 1.0.9 in
--safemode.)jesseleite commentedon Sep 1, 2015
...Oh I see what's going on here. Let me follow up on my last comment.
Auto Indent On Pasteis trying to auto-indent the block as a whole, based on first line's indentation:Whereas PHPStorm is also fixing indentation within the block, making sure each line auto-indents correctly:

IMHO, maybe there should be more consistency between manually running
Auto Indent, andAuto Indent On Paste, since runningAuto Indentmanually is smart enough to fix the mess.Thoughts?
9 remaining items
markiragoldberg commentedon Jun 27, 2017
Thanks @patstew, your work made Atom much more usable for me.
clusteratlas commentedon Sep 5, 2017
This is fucking awesome, thank you very much.
CodeKiwi commentedon Sep 6, 2017
@patstew Awesome, this has been bugging me for a while. I did notice one unexpected thing. When pasting over the existing block it removes the indent when it shouldn't. Not that this is a particularly realistic use case (why would you paste over a block with the same content). Just thought you might like to know. See screenshots (first is copy, second is paste).
lennartq commentedon Oct 25, 2017
@CodeKiwi I actually duplicate a selection by Ctrl-C, Ctrl-V, Ctrl-V, pasting over the original. Not sure how common that is.
TimvdLippe commentedon Oct 29, 2017
This might be fixed with #15976.
stale commentedon Oct 29, 2018
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.
stale commentedon Oct 29, 2019
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.
lock commentedon May 20, 2020
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
lock commentedon May 20, 2020
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
lock commentedon May 20, 2020
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!