ahkpp icon indicating copy to clipboard operation
ahkpp copied to clipboard

Wrong indentation on copy-paste

Open helperman opened this issue 2 years ago • 6 comments

Description

I like to indent code of each separate hotkey in AHK-script. It makes code more readable and clean. The issue is when after copy-pasting a code with indentation the pasted code looses this indentation.

Reproduction steps

0000000735

Expected behavior

Indentation is the same as in a copied text.

Actual behavior

There is no indentation in a copied text.

helperman avatar Sep 24 '23 09:09 helperman

What happens when you run Format Document (Shift+Alt+F)? The document should look nice and indented:

Code_-_Insiders_g2mZYqbBFf

mark-wiemer avatar Sep 30 '23 03:09 mark-wiemer

Yes, Shift+Alt+F fixes indentation. Therefore, the issue is pasting, not formatting. I suspect trim spaces makes place when copying/pasting.

helperman avatar Sep 30 '23 07:09 helperman

I think format-on-paste is out of scope of this extension, maybe you have some other setting messing things up? Does this issue occur when you disable this extension and try to reproduce the issue?

mark-wiemer avatar Oct 11 '23 23:10 mark-wiemer

I also find this frustrating, that the indentation, included in the copied code is removed when pasted after a hotkey or label, but I do find that if you perform an 'undo' Ctrl+Z immediately after pasting, the indentation will be restored.

Note: Indent Code After Label in the settings doesn't appear to work - is this related?

fade2gray avatar Oct 11 '23 23:10 fade2gray

Note: Indent Code After Label in the settings doesn't appear to work - is this related?

This setting was introduced for old formatter (when you hit Alt+Shift+F hotkey), it will format whole file, it didn't work with selected or pasted text.

kyklish avatar Oct 12 '23 11:10 kyklish

Removing this lines may fix copy-paste behavior.

kyklish avatar Oct 12 '23 11:10 kyklish

Closing this as won't fix given how minor it is. I recommend using braces to automatically indent code:

F1::
{
    MsgBox % "Hello world"
    Return
}
F2::
{
    MsgBox % "Hello world"
    Return
}

mark-wiemer avatar Oct 17 '24 14:10 mark-wiemer