Skip to content

Conversation

FedeLoch
Copy link
Contributor

@FedeLoch FedeLoch commented Sep 2, 2025

Fixing cursor movements between lines + Improvement editor actions model + adding editor test cases + improving editor tests builders

In this pr, with @m-demare and @JMLF, we were working on the text editor features. In particular, we modelled the concept of a visual column. As part of this work, we improved the text editor model by representing Editor Actions. Each action now knows about how much to move the cursor.

The editor, on the other hand, is the one who is familiar with the visual and virtual columns.

As part of this work, we improved the editor text test builders by simplifying the contract with these methods. Here is an example of what a new test case looks like:

	self assertFrom: 'self ¶aaaasaasaa<r><t>test' applying: { down . up }
		equals: 'self ¶aaaasaasaa<r><t>test'
	cmd := [:t | t moveLeftCmd: true opt: true ]. "<- A command is a block that knows how to build an editor action"
	
	self assertFrom: 'woArd1 ads¶ word2 word3' applying: { cmd . cmd }
		equals: 'wo¶Ard1 ads word2 word3'

The new model considers the next actions:

  • RubMoveDownAction
  • RubMoveLeftAction
  • RubMoveRightAction
  • RubMoveUpAction
  • RubMovePageUpAction
  • RubMovePageDownAction
  • RubMoveEndAction

The feature fix

Before

Before the behavior/experience was as follows:

Screen_Recording_2025-09-26_at_15.07.07.mov

After

Note that the cursor position "remembers" the original column position ( visual position ):

Screen_Recording_2025-09-26_at_15.03.23.mov

We introduce a test case for each possible scenario regarding this feature ( pressing shift and/or cmd while you move the cursor). Also, we added new test cases for those scenarios that weren't contemplated before.

We also removed the deprecated behavior.

Copy link

request-info bot commented Sep 2, 2025

This issue has either a default title or empty body. We would appreciate it if you could provide more information. Note: I am not a very intelligent bot, I can only react to new comments. Please add a comment for me if you update the body or title.

@FedeLoch FedeLoch marked this pull request as draft September 2, 2025 13:29
Copy link
Contributor

@m-demare m-demare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done during the latest sprint, but we didn't have the time to finish. TODOs:

  • Invalidate virtualColumn when:
    • Text is inserted
    • Text is deleted
    • There's a mouse click
    • Probably other cases I'm forgetting
  • Remove/deprecate methods that've become unnecessary
  • Test if all actions still work fine with shift
  • Write a PR description

@FedeLoch FedeLoch marked this pull request as ready for review September 26, 2025 12:44
@FedeLoch FedeLoch changed the title Fixing bugs and adding test cases Fixing cursor movements between lines + Improvement editor actions model + adding editor test cases + improving editor tests builders Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants