Move lines with Alt+Up/Down#230
Conversation
|
@microsoft-github-policy-service agree |
lhecker
left a comment
There was a problem hiding this comment.
Damn, that's a thorough PR. 😅 This may take me a bit to come back to, as I focus on bug fixes first.
There's also #166 which is a competing solution for this. I believe yours is likely to be more correct though. I think I may just merge the other one first and then yours, given that the other PR is very small.
|
for sure. No problem. And no pressure btw, I know this project got a pretty big hug of death from the community and you got a lot on your plate rn so thanks for even looking at this. I might look for some other smaller things to tackle. GL! |
124d978 to
d37c46f
Compare
- Respects vscode functionality: - 1. if no selection is made, move the line at the current cursor up/down - 2. if a selection is made, move all lines spanning the selection up/down
d37c46f to
15d9953
Compare
|
This solution is definitely better than mine is currently. I'm probably going to rewrite mine soon-ish to be closer to this. Not trying to make this some sort of competition though xD |
|
After a bit of thinking, I think my solution should be retired. This is like... 10x better. |
…election_lines_with_alt_up_down
|
|
||
| self.cursor_move_to_logical(Point { x: 0, y: paste }); | ||
| self.edit_begin(HistoryType::Write, self.cursor); | ||
| if line.is_empty() || self.cursor.logical_pos.y != paste { |
There was a problem hiding this comment.
|| self.cursor.logical_pos.y != paste
what common occurrence does this handle? The cursor couldn't be moved to the paste line, so it's not on the paste line..?
There was a problem hiding this comment.
Oh, I wanted to document this code before submitting it and forgot. Let me fix that.
DHowett
left a comment
There was a problem hiding this comment.
It's beautiful. Thanks both of you for working on it
Closes microsoft#27 Co-authored-by: Leonard Hecker <leonard@hecker.io>
Closes #27
In this pr
[feat]: move cursor or selection lines with alt+up/down
[dev][feat]: add tests for
move_selected_linescommandImportant
I couldnt figure out how to get the TextBuffer's scratch arena to work with parallel tests so they need to be run with
--test-threads=1Additional Notes
Atm undoing an operationctrl+zsets the selection to the entire range of the source text & swap location text.This is due to how i use a selection to make sure im writing to the correct location withTextBuffer.write()This is wrong and the restored selection should be the original selection before the move.Any suggestions on correcting this?scratch_arena?Resultreturn instead of a boolean for the failure cases.images

