Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

"Normalize Indent on Paste" does not normalize indent on paste. #110

Closed
NatalieWolfe opened this issue Apr 16, 2014 · 17 comments
Closed

"Normalize Indent on Paste" does not normalize indent on paste. #110

NatalieWolfe opened this issue Apr 16, 2014 · 17 comments
Labels

Comments

@NatalieWolfe
Copy link

In fact it does the opposite.

normalize

I would have expected the pastes when "Normalize Indent on Paste" is on to be aligned with the other function definitions, but they are instead always inserted at column 1.

@probablycorey
Copy link

This is the expected behavior, but I can see how it is confusing. The current implementation normalizes the indent based on the cursor position.

Are you looking for a behavior that would auto-indent on paste?

@NatalieWolfe
Copy link
Author

I misunderstood the feature as normalizing the indentation of the copy-buffer with the code around it, not to paste at the cursor's depth. I unfortunately don't have a way to make a gif of what I mean (as the feature doesn't exist in Atom, Sublime Text, or NetBeans which are the only editors I have).

Lets say you have the following text in your buffer (dots for spaces for illustrative purposes):

..function foo(){
....// Do some stuff.
..}

And you paste it into a file containing this code (pipe is where the cursor is):

(function(){
....function bar(){
........// Do some other stuff.
....}

|
})();

Atom would recognize that the copy-buffer is using 2-space indentation and the file is using 4-space. Then it would "normalize the indentation" of the copy-buffer to match the file and you get:

(function(){
....function bar(){
........// Do some other stuff.
....}

....function foo(){
........// Do some stuff.
....}
})();

In my original gif example, this feature would appear to do nothing because the copy-buffer and the paste target have the same indentation.

Since the original "bug" is actually a feature, do you want me to create a new ticket requesting this feature?

@mathieujobin
Copy link

I was also expecting Atom to adjust indent on paste.

@qstrahl
Copy link

qstrahl commented Oct 8, 2014

👍

@ghost
Copy link

ghost commented Nov 1, 2014

Same problem here. When I have that option enabled, and I paste, I expect it to maintain the proper indentation for the entire block of code pasted. For now, a workaround is to paste, then select the pasted code and choose Edit > Lines > Auto Indent.

On a side note, @NatalieWolfe : how did you make that animated GIF screen cap?

@NatalieWolfe
Copy link
Author

@CaptSaltyJack http://www.cockos.com/licecap/ Very handy for demonstrating bugs. :)

@ghost
Copy link

ghost commented Nov 1, 2014

Wow, very handy indeed. Pro-tip of the month, easily! Thanks!

@ghost
Copy link

ghost commented Nov 1, 2014

Hmm, hang on. As of 0.141.0, Normalize Indent seems to work as expected.

@NatalieWolfe
Copy link
Author

The feature still functions exactly as in my original gif for me with Atom 0.141.0 on Mac OS X 10.10.

@ghost
Copy link

ghost commented Nov 3, 2014

I had it misbehave again once. It seems intermittent.

@jerone
Copy link
Contributor

jerone commented Jan 14, 2015

Is this option still available, because I can't find it in Settings > Settings > Editor Settings ?

@NatalieWolfe
Copy link
Author

I think the name of the option changed to "Auto Indent On Paste" and is now fixed, hooray!

autoindent

@jlord
Copy link

jlord commented Mar 9, 2015

Yep, looks good now ✨

@jlord jlord closed this as completed Mar 9, 2015
@jerone
Copy link
Contributor

jerone commented Mar 26, 2015

@NatalieWolfe commented on 15 jan. 2015 21:04 CET:

I think the name of the option changed to "Auto Indent On Paste" and is now fixed, hooray!

I still see this option for some language grammars. For example language-jade and language-sln. Is this an issue for here or an issue for those packages? The option also appears as an text field, instead of the previously used checkbox.

normalize indent on paste

@NatalieWolfe
Copy link
Author

If the option is in the settings for those language packages, then you should probably report the issue on those packages.

@polarathene
Copy link

Is there a way to get it so pasting code where the cursor is already indented rather than at the start of the line works in the same way?

I was 2 indents in, pasted 3 lines with no indentation and the next 2 lines started at the start of a line rather than keeping consistent indent level. If I remove the current indent so the cursor is at the start of the line prior to the paste, code is indented consistently at 2 indents in.

@ilyashubin
Copy link

@polarathene +1, always causing frustration

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

No branches or pull requests

9 participants