Another small Q: selecting test and text endings

129 views
Skip to first unread message

jkn

unread,
Jun 27, 2022, 4:24:58 AM6/27/22
to leo-editor
(I am scratching a few small itches at the moment...)

My particular use case is this. If I am on the last line of the body of a node,
and my cursor is at the beginning of that line, then I cannot select the line by
<shift-down>. I have to either:

- use <shift-end> instead (inconsistent)
- add an EOL to the line and then retry.

I had vaguely thought that there were some Leo settings relating to selection and
cursor movement around line endings, which might govern this.
However I can't find them - perhaps I am thinking of a different editor.

Am I missing something?

Thanks, J^n



tbp1...@gmail.com

unread,
Jun 27, 2022, 8:41:00 AM6/27/22
to leo-editor
I get annoyed by this too.  If you just want to move the line up, a line or block of lines can be moved with CNTL-Uparrow and CNTL-Downarrow.  These are a useful habit to acquire, even though it doesn't solve the case where you actually do want to select the last line.

Edward K. Ream

unread,
Jun 27, 2022, 9:23:38 AM6/27/22
to leo-editor
On Mon, Jun 27, 2022 at 7:41 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I get annoyed by this too.  If you just want to move the line up, a line or block of lines can be moved with CNTL-Uparrow and CNTL-Downarrow.  These are a useful habit to acquire, even though it doesn't solve the case where you actually do want to select the last line.

I agree this can be annoying. Do you want to attempt a fix?

Edward

Edward K. Ream

unread,
Jun 27, 2022, 9:28:29 AM6/27/22
to leo-editor
On Monday, June 27, 2022 at 8:23:38 AM UTC-5 Edward K. Ream wrote:

I agree this can be annoying. Do you want to attempt a fix?

I have just created #2697 for this issue.

Edward

tbp1...@gmail.com

unread,
Jun 27, 2022, 11:02:25 AM6/27/22
to leo-editor
I understand that the desired action is this:

   If the cursor is on the last line of the body and SHIFT-DOWN is pressed, then the selection will be extended to include the entire last line.
   The cursor will also move to the end of the last line.

Is there anything else that should happen, or any other user action that should be included?

tbp1...@gmail.com

unread,
Jun 27, 2022, 2:42:26 PM6/27/22
to leo-editor
PR 2698 handles this (when merged).

jkn

unread,
Jun 27, 2022, 4:00:10 PM6/27/22
to leo-editor
That is how I would explain the desired action, and thank you for working on the PR (and Edward for raising it); I will try it shortly.

I would suggest that it is made a configurable option; as I mention I am sure I have seen something like this as a configurable option
in A.N.Other editor. I am trying to remember which. It may be that the new action is annoying to some.

It was probably connected with the idea of 'virtual space; whether you can navigate with the cursor beyond the end of text
in a node. Leo doesn't let you do this. Some editors do; then if you start adding characters, they fill the space between
the previous end of text in that node, and your current cursor position, with a combination of EOLs and spaces.

I see that Notepad++ has an 'enable scrolling beyond last line' option, which is probably similar. Note that
(I'm not requesting this feature for Leo...

Thanks, J^n

tbp1...@gmail.com

unread,
Jun 27, 2022, 5:22:12 PM6/27/22
to leo-editor
I think the new way it works agrees with the principle of minimum surprise.  At least, I was always surprised when Shift-Down didn't select the last line.  And with this change, a down arrow without a Shift puts the cursor at the end of the last line, which is also what I seem to expect.

I suppose an alternative would have been to have Shift-Down insert a new line at the bottom and select to there, but I didn't favor that because an unrequested insert can be a surprise - and when the selected line gets deleted, which has to be the most common use case, should the newly inserted line be deleted too?  Hmm....

I'd rather not make it configurable unless someone complains.  Why complicate the code when chances are everyone will like the new way, if they even notice?

tbp1...@gmail.com

unread,
Jun 27, 2022, 5:24:27 PM6/27/22
to leo-editor
On Monday, June 27, 2022 at 4:00:10 PM UTC-4 jkn wrote:
That is how I would explain the desired action, and thank you for working on the PR (and Edward for raising it); I will try it shortly.
Wait until the PR is actually accepted and merged ... it's not yet ... 

Edward K. Ream

unread,
Jun 28, 2022, 2:11:43 AM6/28/22
to leo-editor
On Monday, June 27, 2022 at 1:42:26 PM UTC-5 tbp1...@gmail.com wrote:
PR 2698 handles this (when merged).

I'm having trouble testing the code. Maybe I'm not using git correctly. Here's what I did:

- In the PR's main page, I clicked the link that says tbpassin:tbp-leo-general.

- In that page, I copied the "Code" link, whose contents is:

- In my Repos directory, I did `git clone https://github.com/tbpassin/leo-editor.git tbp`

- cd tbp

- I don't see the new code, and gitk doesn't show any commits.

I wonder what I did wrong.

Edward

tbp1...@gmail.com

unread,
Jun 28, 2022, 8:43:21 AM6/28/22
to leo-editor
After I pushed my change to Github, Github recognized that I had made a commit and offered to create a PR, which I accepted.  So at that time Github knew there had been a commit.  I also see that the changes are in my Github leo-editor repo, starting at line 1796 in qt_text.py.

The branch is not devel but tbp-leo-general.

Otherwise, I can't help you with git mysteries.  I always get lost!

tbp1...@gmail.com

unread,
Jun 28, 2022, 9:24:11 AM6/28/22
to leo-editor
On Tuesday, June 28, 2022 at 2:11:43 AM UTC-4 Edward K. Ream wrote:
On Monday, June 27, 2022 at 1:42:26 PM UTC-5 tbp1...@gmail.com wrote:
PR 2698 handles this (when merged).

I'm having trouble testing the code. Maybe I'm not using git correctly. Here's what I did:

- In the PR's main page, I clicked the link that says tbpassin:tbp-leo-general.

- In that page, I copied the "Code" link, whose contents is:

- In my Repos directory, I did `git clone https://github.com/tbpassin/leo-editor.git tbp`

I navigated to that page.  When you press the "Code" button (as you did),  you also get an option to download a zip file.  I downloaded it and yes, it does have my changes.

Edward K. Ream

unread,
Jun 28, 2022, 11:18:15 AM6/28/22
to leo-editor
On Tue, Jun 28, 2022 at 7:43 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
After I pushed my change to Github, Github recognized that I had made a commit and offered to create a PR, which I accepted.  So at that time Github knew there had been a commit.  I also see that the changes are in my Github leo-editor repo, starting at line 1796 in qt_text.py.

Thanks for these comments. Something strange is happening. I'll continue to investigate.

Edward

Jacob MacDonald

unread,
Jun 28, 2022, 12:33:44 PM6/28/22
to leo-editor
Edward K. Ream wrote:
>> - In that page, I copied the "Code" link, whose contents is:
>> https://github.com/tbpassin/leo-editor.git
> Something strange is happening. I'll continue to investigate.

The instructions GitHub gives you to clone don't change based on which
branch you're viewing. In the tbp directory, you need to run `git
checkout tbp-leo-general` and then should see the new code.

Jacob.

Edward K. Ream

unread,
Jun 28, 2022, 1:12:03 PM6/28/22
to leo-editor
On Tue, Jun 28, 2022 at 11:33 AM Jacob MacDonald <jacc...@gmail.com> wrote:

In the tbp directory, you need to run `git checkout tbp-leo-general` and then should see the new code.

Thanks, Jacob.  That worked.

Edward

tbp1...@gmail.com

unread,
Jun 28, 2022, 6:34:12 PM6/28/22
to leo-editor
@Edward has merged the PR.

tbp1...@gmail.com

unread,
Jun 28, 2022, 11:41:19 PM6/28/22
to leo-editor
Hmm, this is not quite working as I want.  If you place the cursor in the left-hand column of a line above the last line, and Shift-Down to the last line, the cursor jumps to the end of the last line.  It should go to the start of the last line.  This seems different from what I thought I had worked out.  I'll look at fixing it - probably an off-by-one error or some such.

tbp1...@gmail.com

unread,
Jun 29, 2022, 12:10:57 AM6/29/22
to leo-editor
OK, a fix is proposed in PR 2700.  It wasn't an off-by-one.  It was a missing bit of logic.  I needed to restrict the movement to the end of the last line to the case where the cursor was already on the last line when the Down key is pressed.  I have also tested using a wrapped last line and it works correctly in this case, too.

tbp1...@gmail.com

unread,
Jun 29, 2022, 7:37:28 AM6/29/22
to leo-editor
The new PR has been merged into devel.

jkn

unread,
Jun 29, 2022, 9:42:51 AM6/29/22
to leo-editor
Thanks for the work on this little itch!

Regard, Jon N

tbp1...@gmail.com

unread,
Jun 29, 2022, 10:13:12 AM6/29/22
to leo-editor
And thanks for giving us the little nudge we needed to work on it : )

jkn

unread,
Jun 29, 2022, 4:10:47 PM6/29/22
to leo-editor
Just tried it BTW - seems to be working fine, thanks!

tbp1...@gmail.com

unread,
Jun 29, 2022, 4:27:15 PM6/29/22
to leo-editor
Good! Let us know if there are any quirks ... maybe they can be worked out.  I've been happy so far myself.
Reply all
Reply to author
Forward
0 new messages