kstenschke / shifter-plugin

Intelligent string/code manipulation plugin for Jetbrains IDEs: Detects shiftable type of word/line/selection and manipulates it on keyboard shortcut
http://plugins.jetbrains.com/plugin/6149
Apache License 2.0
105 stars 13 forks source link

Sorting lines in selection problem #2

Closed abysas closed 11 years ago

abysas commented 11 years ago

Not sure that it is a bug or is intended by design, but at the first glance it seemed like a bug: when sorting lines in multi-line selection, plugin sorts separately lines that begin with tab charcter and lines that begin with spaces. Therefore I got strange sorting result which seemed like a bug of the plugin until I turned on whitespace display on IDE which revealed the reason.

As an example here if I sort these lines (where field name in each line indicate how this line starts):

    private String stringSpaced;
    private String stringTabbed;
    private Integer intSpaced;
    private Integer intTabbed;

and as a result got:

    private Integer intTabbed;
    private String stringTabbed;
    private Integer intSpaced;
    private String stringSpaced;

I guess sorting should ignore whitespace at the beginning.

I use Shifter plugin v1.0.11 on Intellij IDEA v11.1.4

kstenschke commented 11 years ago

abysas, thanks a lot for reporting this issue. i appreciate your feedback and thorough example :) though after some thought, i think ignoring whitespace during sorting would reduce possible use cases of the plugin. i would usually recommend to keep indentation/ white space consistent by using either tabs or spaces. (there is a "reformat" option for that in the code menu, CTRL + ALT + L). or can you tell me any reason to intentionally mix whitespace styles (and then sort ignoring it) that i might not have thought of?