action: add block/paragraph selection#2012
action: add block/paragraph selection#2012ljmf00 wants to merge 2 commits intomicro-editor:masterfrom
Conversation
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
|
@zyedidia Any attention to this? This is fairly trivial. |
|
Do we know anything if it's going to be merged anytime soon? |
|
Ping @zyedidia |
|
Any chance this can be merged? Would be a great feature to have. |
|
It's 2024 already, there are no merge conflicts, I'd also quite like this feature please. Why is this basic feature ignored? |
| if line == 0 { | ||
| h.Cursor.Loc = h.Buf.Start() | ||
| } | ||
| h.Cursor.SelectTo(h.Cursor.Loc) |
There was a problem hiding this comment.
h.Relocate() is missing. As a result, when selecting paragraphs beyond the bottom/top of the screen, it doesn't scroll the screen automatically (unlike with ParagraphNext and ParagraphPrevious).
...In fact, looks like this can be implemented much shorter, by reusing ParagraphNext() and ParagraphPrevious() (and that would also automatically take care of scrolling):
// SelectParagraphPrevious select to the previous empty line, or beginning of the buffer if there's none
func (h *BufPane) SelectParagraphPrevious() bool {
if !h.Cursor.HasSelection() {
h.Cursor.OrigSelection[0] = h.Cursor.Loc
}
h.ParagraphPrevious()
h.Cursor.SelectTo(h.Cursor.Loc)
return true
}
// SelectParagraphNext select to the next empty line, or end of the buffer if there's none
func (h *BufPane) SelectParagraphNext() bool {
if !h.Cursor.HasSelection() {
h.Cursor.OrigSelection[0] = h.Cursor.Loc
}
h.ParagraphNext()
h.Cursor.SelectTo(h.Cursor.Loc)
return true
}
...Actually there is one more issue: if there are several empty lines one after another, it just selects those empty lines one by one, as if they were "paragraphs", instead of jumping to selecting the next actual paragraph. But the same issue actually exists with ParagraphNext and ParagraphPrevious as well, so it can be fixed separately.
There was a problem hiding this comment.
In this solution, while it does select the block, the cursor does not get moved with the selection, rather it is projected from the cursor while it stays in place. I would expect block select to drag the selection behind the cursor, essentially being ParagraphNext + selection. In the same way that ctrl+shift+left/right moves the cursor, and all other ctrl+shift combinations.
|
Yep. I even forgot about this one. |
Signed-off-by: Luís Ferreira contact@lsferreira.net
Fixes #1968.