Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore leading spaces when sorting #22

Closed
tomasfejfar opened this issue Jan 6, 2017 · 8 comments
Closed

Ignore leading spaces when sorting #22

tomasfejfar opened this issue Jan 6, 2017 · 8 comments

Comments

@tomasfejfar
Copy link

I try to sort this code with selection as shown below

   	>	$bundles[] = new DebugBundle();
   		$bundles[] = new SensioDistributionBundle();
   		$bundles[] = new WebProfilerBundle();<

(selection shown as >selected text<)

Expected:

   		$bundles[] = new WebProfilerBundle();
   		$bundles[] = new SensioDistributionBundle();
   		$bundles[] = new DebugBundle();
  • Leading whitespace is ignored

Actual:

   		$bundles[] = new DebugBundle(); <------ PROBLEM
   		$bundles[] = new WebProfilerBundle();
   		$bundles[] = new SensioDistributionBundle();
  • Leading whitespace is taken into account.
@krasa
Copy link
Owner

krasa commented Jan 6, 2017

even if it was ignored, the result would be

   			$bundles[] = new WebProfilerBundle();
   		$bundles[] = new SensioDistributionBundle();
	$bundles[] = new DebugBundle();

@krasa
Copy link
Owner

krasa commented Jan 6, 2017

how about using multicaret with empty selection:
image

I would just need to implement selection of the whole line when nothing is selected - which should have been there from the beginning anyway.... right now only Sort by subselection does that.

@tomasfejfar
Copy link
Author

That would solve it for me, although it's not very intuitive for anyone not knowing about it. I actually am quite sure that expanding to the whole line should be default for everything. I failed to come up with any actual use-case for the "Actual" case above where it would make sense. Do you have one?

@krasa
Copy link
Owner

krasa commented Jan 7, 2017

imho if you select something, you would expect the operation to be done on the exact selection - or if you select nothing, it will select lines with carets - just like ctrl+c does.

But you are right that ignoring whitespaces (so that you get the right order) + preserving spaces (so that it does not break formatting) would be nice + preserving trailing commas (as someone else wants) should cover everything.... Even this:
image

@tomasfejfar
Copy link
Author

tomasfejfar commented Jan 7, 2017

This seems like a meaningful use to partial-line selection that should not expand, you are right.

ignoring whitespaces (so that you get the right order) + preserving spaces (so that it does not break formatting) would be nice + preserving trailing commas (as someone else wants) should cover everything

Exactly. You actually explained my thoughts better than I did myself, thanks.

krasa added a commit that referenced this issue Jan 8, 2017
krasa added a commit that referenced this issue Jan 8, 2017
krasa added a commit that referenced this issue Jan 8, 2017
(cherry picked from commit 5af681a)
@krasa
Copy link
Owner

krasa commented Jan 8, 2017

krasa added a commit that referenced this issue Jan 8, 2017
… it works more reliably (for the price of perhaps altering the lines too much)
krasa added a commit that referenced this issue Jan 8, 2017
krasa added a commit that referenced this issue Jan 9, 2017
krasa added a commit that referenced this issue Feb 10, 2017
@krasa
Copy link
Owner

krasa commented Feb 11, 2017

Done and released.

@krasa krasa closed this as completed Feb 11, 2017
@tomasfejfar
Copy link
Author

I forgot to thank you :) I'm using it regularly and it works great.

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

No branches or pull requests

2 participants