Skip to content

Set Tk selection anchor when using Home/End keys - #1923

Merged
windymilla merged 3 commits into
DistributedProofreaders:masterfrom
windymilla:selection-highlighting
Aug 13, 2026
Merged

Set Tk selection anchor when using Home/End keys#1923
windymilla merged 3 commits into
DistributedProofreaders:masterfrom
windymilla:selection-highlighting

Conversation

@windymilla

Copy link
Copy Markdown
Collaborator

When used without Shift, Home/End (Cmd-Left/Right on Macs) should set the selection anchor so that future adjustment of the selection works more predictably.

Fixes #1920

When used without Shift, Home/End (Cmd-Left/Right on
Macs) should set the selection anchor so that future
adjustment of the selection works more predictably.

Fixes DistributedProofreaders#1920
@windymilla
windymilla requested a review from srjfoo August 9, 2026 14:36
@tangledhelix

Copy link
Copy Markdown
Member

This still does the wrong thing when (on Mac only) you move the cursor to start/end of line with Ctrl-A (start) or Ctrl-E (end).

@tangledhelix

Copy link
Copy Markdown
Member

Strangely, though, it does work if you don't involve arrow keys in it!

Works:

  • Click in middle of some line
  • Ctrl-A to jump to start of line
  • Shift-Ctrl-E to select to end of line
  • Shift-Ctrl-B to move backward 1 char (selection is now entire line minus last character)

(The same is true in reverse: Ctrl-E, Shift-Ctrl-A, Shift-Ctrl-F.)

Doesn't work:

  • Click in middle of some line
  • Ctrl-A to jump to start of line
  • Shift-Cmd-Right to select to end of line
  • Shift-Cmd-Left to move backward 1 char

This leaves the selection from where you clicked until just before the last char in the line.

@srjfoo

srjfoo commented Aug 9, 2026

Copy link
Copy Markdown
Member

Doesn't work:

  • Click in middle of some line
  • Ctrl-A to jump to start of line
  • Shift-Cmd-Right to select to end of line
  • Shift-Cmd-Left to move backward 1 char

This leaves the selection from where you clicked until just before the last char in the line.

For the last bullet point, Shift-Cmd-Left should take you back to the beginning of the line. Did you mean Shift-Left?

@tangledhelix

Copy link
Copy Markdown
Member

Yes

@srjfoo

srjfoo commented Aug 11, 2026

Copy link
Copy Markdown
Member

The simple case now works. That is ...

  • Click in middle of line
  • Use cmd (on Mac) plus arrow1 key to go to one end of the line.
  • Use shift+cmd+arrow2 key to select to the other end of the line
  • Release cmd and use just shift+arrow1 to trim selection

Where arrow1 and arrow2 are left and right arrow keys (or right and left, depending on which direction the initial move is).

Doesn't work:

  • Click in middle of some line
  • Ctrl-A to jump to start of line
  • Shift-Cmd-Right to select to end of line
  • Shift-Cmd-Left to move backward 1 char

This leaves the selection from where you clicked until just before the last char in the line.

For the last bullet point, Shift-Cmd-Left should take you back to the beginning of the line. Did you mean Shift-Left?

Confirmed this result of Dan's

Also discovered another failure mode:

If, when I click in the middle of a line, I have the shift key down and arrow to the left or the right, then catch myself and change from shift to cmd and go to one end of the line or the other, I see the same behavior as above (which mirrors the original problem).

@windymilla

Copy link
Copy Markdown
Collaborator Author

I'm not certain, since I can't test it, but hopefully this fixes the Ctrl-a/e problem. Please check they work as expected generally, not just this specific case. Also, please re-rest Cmd-left/right because the Ctrl-a/e fix slightly affects that too.

@srjfoo if you test your second bug, that may have been fixed by this. If not, please can you describe it more precisely for me, specifically, what you expect to happen and what you see that is unexpected. I tested it as best I could on Windows, but couldn't do exactly what you describe of course.

@srjfoo srjfoo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

@tangledhelix tangledhelix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The case I outlined earlier that didn't work, now works 👍🏻

The other case I mentioned, which was already working, still works too. LGTM!

@windymilla
windymilla merged commit 2fdf197 into DistributedProofreaders:master Aug 13, 2026
1 check passed
@windymilla
windymilla deleted the selection-highlighting branch August 13, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selection highlighting changes unpredictably when adjusting with Shift + Arrow keys

3 participants