Repository navigation
Feature/album issue 70 - #72
Merged
tinchodias merged 4 commits intoOct 30, 2026
Merged
Conversation
Keyboard selection (Shift+arrows, word and line start/end) now extends or shrinks a selection at every cursor instead of collapsing to the primary one. Typing, paste and deletion apply to every selection. - AlbTextEditorSelecter: extension operations build one command per cursor (new private...For: methods) and move all cursors with a single navigator apply - AlbTextEditorNavigator: optional merging of cursors within the same selection (withMergingWithinSelection), keeping one cursor at the selection edge; the selecter triggers it once the editor selection is up to date - Explicit ranges (select all, mouse drag, Shift-click) still keep a single cursor Requires the BlSelectionTree>>delete: fix in Bloc. Replace test_selecting_keeps_only_the_primary_cursor with 10 selection tests in AlbMultiCursorTest.
Paste: when there are several cursors and the pasted text has exactly as many lines, each cursor gets one line, in text order. Otherwise the whole text is pasted at every cursor, as before. A trailing line ending does not count as an extra line. Copy/cut: copySelected and cutSelected used the span from the first to the last selection, so with several selections they copied (and cut) the unselected text in between. Each selection is now copied separately, one per line (new AlbTextEditor>>selectedTexts), and cut removes only the selected ranges. A single selection behaves as before. Cleanup: - AlbTextEditorNavigator: initialize shouldMergeWithinSelection to false instead of testing it against true - AlbTextEditorSelecter: remove commented-out code from privatePerformSelectAndDeselectCommands: - AlbExtendSelectionCommand: remove the unused toRemoveCursors slot - Formatting of the new private...For: methods in AlbTextEditorSelecter Add 8 copy/paste tests to AlbMultiCursorTest. Tests touching the system clipboard restore it afterwards.
Newer Bloc forbids #forceLayout on elements attached to a space. AlbMultiCursorTest now subclasses BlSpaceTestCase: element-based tests add the editor to the test space and perform edits within space deferAndSettle:, and cursor elements are collected after space settle.
Closed
Collaborator
|
Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR replaces #71, which started from the wrong branch.
Adds VS Code-style multi-cursor editing to the Album text editor, as requested by #70.
Try it
AlbTextEditorExamples exampleMultiCursorEditingopens an editor with a cursor at the start of every line.Changes
Cursors
AlbTextEditorkeeps its primarycursorand gainssecondaryCursors.cursorsreturns all cursors sorted by position. New:addCursorAt:,removeSecondaryCursors,hasMultipleCursors.AlbTextEditorNavigator:moveBy:,moveWithin:) apply to every cursor.moveTo:/moveToScreenPosition:collapse to a single cursor;addAt:keeps its existing meaning.addCursorAt:,removeCursorAt:,removeSecondaryCursors;removeAt:(sent by the history but previously missing) is implemented.applymerges cursors at the same position. Removing the primary cursor promotes a secondary one; the last cursor is never removed.Selections
AlbTextEditorSelecter: keyboard extensions build one command per cursor (private...For:methods) and move all cursors with a single navigator.withMergingWithinSelection, triggered at the end ofselectonce the editor selection is up to date).Copy / paste
AlbTextEditor>>selectedTexts.copySelectedcopies one selection per line;cutSelectedremoves only the selected ranges. Previously, with several selections, they used the span from the first to the last selection, so cut deleted the unselected text in between.AlbTextEditorPaster>>pastedistributes lines over cursors (VS Code rule; a trailing line ending does not count).Rendering
applyis two-phase: remove all cursors from their old segments, update the model, then re-add them, so cursors sharing a segment do not hide each other.AlbTextElementholds secondary cursor elements next to the editor's shared primary cursor element.Shortcuts and mouse
AlbEditorAddCursorAboveShortcut/AlbEditorAddCursorBelowShortcut; Escape (AlbEditorDeselectAllShortcut) also removes secondary cursors; Alt/Option-click inAlbTextEditorMouseHandler.Cleanup
toRemoveCursorsslot fromAlbExtendSelectionCommandand commented-out code fromprivatePerformSelectAndDeselectCommands:.Tests
AlbMultiCursorTest(46 tests), aBlSpaceTestCase: element-based tests run in the test space withspace deferAndSettle:(newer Bloc forbidsforceLayouton attached elements). The notation'a|b|c'means the textabcwith cursors at 1 and 2. Coverage:AlbTextEditorHistoryTest: two redo regression tests for multi-index insertion. One of them wraps a selection in parentheses, then undoes and redoes, a pre-existing single-cursor bug.AlbTextEditorByScripterTest(upstream) needs theBloc-Simulationpackage, which the full Bloc baseline loads.Dependency
Requires pharo-graphics/Bloc# (requested indices in
BlTextStringsInserted, deletion inBlSelectionTree). Without it, the multi-index redo tests and two selection tests fail.See pharo-graphics/Bloc#895
Limitations
AlbCursorElement>>defaultBlinkingis false). When blinking is enabled withcursorElement beBlinking: true, only the primary cursor blinks; synchronized blinking will come in a separate PR.