-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Request: Shortcut to reorder list item #170
Comments
Maybe elm-format could be able to fix wrongly formatted lists after a move? Not sure if that would work |
Re elm-format, the next version is planned to remove unnecessary commas that are at the beginning or end of a list. But having the initial square bracket be allowed to be a comma instead is something I haven't looked into, and I suspect it would probably make the syntax too ambiguous to parse performantly. |
I took a shot at how this could be implemented :D There are some issues I'm aware of though: How to handle comments: Example elm-format formatted code rangeSlider
-- General List Comment?
[ -- First item comment
Html.Attributes.max "11"
-- Is this commenting the next item?
, -- Or is this the comment for the next listitem
onSlide toMsg
, Html.Attributes.property "val" (Json.Encode.int magnitude)
] I think this should move the comments as well if there are any, and this would be easy if the comments were placed within the same list item. But not sure how to handle comments on last line before next list item. Cursor The cursor does not follow along, and this makes adding smooth keyboard shortcuts less possible. Not sure if there are any fixes for this. I would have liked to add "Ctrl-Alt-Shift-Up" as a move the current item up in the list, with possibility for repeated keypresses. But I'm not sure if that is possible if the cursor does not follow along. Currrently all code is within a CodeAction in the Language Server, so it is VSCode independent. I'm not proficient in TypeScript, and hacked this together. If its interesting to add I can try refactoring to something testable. https://github.com/Strepto/elm-language-server/tree/swaplistitems-codeaction |
Yeah, that shouldn't be hard to do. In the server as code action. Probably
not as ergonomic as move line up/down via keyboard.
…On Sat, Feb 27, 2021, 13:42 Nils Henrik Hals ***@***.***> wrote:
[image: moveactions]
<https://user-images.githubusercontent.com/3185998/109387402-8fd59700-7901-11eb-8a78-385cfd5e19e0.gif>
I took a shot at how this could be implemented :D
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#170 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABNLEZBQYH5PEKQYEXAU6GLTBDSDLANCNFSM4YJARDOA>
.
|
@razzeee I see you replied to the email, I edited the post with a bit more information, and a link to the code I used. As you say the actual CodeAction was not that hard to create, even though its just hacked together. |
Code seems good, just some things we can improve, missing tests being the obvious one. Otherwise we'll nee microsoft/language-server-protocol#724 to make this truly powerful, but I don't see much harm in already shipping it like this. |
I took a shot at writing some tests, but could not get them to run correctly. I I'm not proficient enough to fix/understand the boilerplate. The issue is that "edit" on this line is undefined, and the test throws: https://github.com/elm-tooling/elm-language-server/blob/032707ab925b841d6829140e7f87c3b7c80b9934/test/codeActionTests/codeActionTestBase.ts#L135 |
I think sending a WIP merge request would be the best way to move forward :) |
Expected Behavior
When moving a list item, I would like to be able to move an item in a (vertical) list up or down without manually shuffling commas and brackets, and knowing where the actual ending comma for this line item is. This could/should also be applied to horizontal lists if this is possible.
Current Behavior
If I want to move paragraph
Apple
belowOrange
I can press Alt-Down with the cursor and the lines will shuffle, and no manual changes needed.BUT If I want to swap
Pear
andApple
, i can swap these using Alt-Up/Down. But I then need to replace the initial[
ofPear
with a leading,
comma, and replace the leading comma fromApple
with a starting bracket.This is even more a feature that would be great if it would support multiple line content in lists.
If I could have my caret on the "paragraph on line 1, and press a key to move it and all implementation down in the list without having to select, move, replace commas and brackets and all that churn work, this would be a fantastic feature in my mind.
I would also like to be able to move items in such lists with the same shortcut (but it is not a priority). If I have my caret on Orange and press the shortcut I would swap
Apple
andOrange
.Context
Since elm language clients has access to the syntax tree I believe this could be added, but I have no idea how. This feature might actually already exist, but I have not found it. If it does I would be happy to know :)
Is this an interesting proposal, and is it something that could be contributed if so?
And is this a question for the vscode addon or the Elm-LanguageServer?
The text was updated successfully, but these errors were encountered: