-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add limited support for :sort #1342
Conversation
Hmmm, you could have used editor.action.sortLinesAscending and editor.action.sortLinesDescending I think? Then you could just add a file like this https://github.com/VSCodeVim/Vim/blob/master/src/cmd_line/commands/quit.ts but for sort, and have it call those 2 commands |
@xconverge That'd be super nice not to have to roll my own sorting routine. Is there a way we can support a line range whilst doing that? For example: |
src/cmd_line/subparsers/sort.ts
Outdated
|
||
export function parseSortCommandArgs(args : string) : node.SortCommand { | ||
|
||
let reverse_ = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the trailing underscore? Also you could write const reverse = args !== null && args.indexOf("!") >= 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No specific reason, my bad. Will update the conditional as well.
- Works on a range - ! option is supported to reverse the sort - Other options not supported at this time Fixes: VSCodeVim#1341
99e4a40
to
4995d2d
Compare
@jordan-heemskerk I think you would have to set the selection to contain those lines and then run the command Might just be easier to keep the homegrown one though since a sort isn't too complicated |
@xconverge yeah, my thinking as well if that is the case. Especially since that sorting routine may grow more complex to support the full option list of |
the failing test isn't you |
Yeah looks like |
src/cmd_line/subparsers/sort.ts
Outdated
const reverse = args !== null && args.indexOf("!") >= 0; | ||
|
||
return new node.SortCommand({ | ||
reverse: reverse, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact: { reverse: reverse }
can be better written in ES6 as { reverse }
. :)
Heh I forgot I can make little tweaks directly from Github. That's a new feature :) Alright, this LGTM! Thanks for the PR, @jordan-heemskerk 😄 |
Fixes: #1341