trying to indent line with 'tab' also inserts newline in 6.3

76 views
Skip to first unread message

gar

unread,
Nov 9, 2020, 9:56:42 AM11/9/20
to leo-editor
switched to 6.3 recently and discovered the subject.
so when you press 'tab' in front on the line - you get another unwanted empty line right above it and plus your current line gets wanted indentation.

what did I wrong with it? what is the proper way of indenting single lines w/o selecting them and using 'indent-region' command?

gar

unread,
Nov 9, 2020, 10:01:50 AM11/9/20
to leo-editor
also I see that auto-indent after if/else/{ in my custom language highlight rule became broken - it does not indent anything
builtin python mode works as expected (but tab indentation is still broken)

понедельник, 9 ноября 2020 г. в 17:56:42 UTC+3, gar:

gar

unread,
Nov 10, 2020, 3:24:00 AM11/10/20
to leo-editor
and another very bad thing is that editor's cursor may occasionally hang for a second
it may happen on undo action, on coloring string on finish with ", on  deleting the whole word with ctrl-bs
it annoys a lot, and this is introduceв in 6.3

Edward K. Ream

unread,
Nov 10, 2020, 4:07:02 PM11/10/20
to leo-editor
On Tue, Nov 10, 2020 at 2:24 AM gar <gar...@gmail.com> wrote:
and another very bad thing is that editor's cursor may occasionally hang for a second
it may happen on undo action, on coloring string on finish with ", on  deleting the whole word with ctrl-bs
it annoys a lot, and this is introduced in 6.3

Iirc, there was a change in Leo's operation with 6.3.  You may have to change your myLeoSettings.leo to match the new leoSettings.leo as far as tab bindings go.  The relevant entries in leoSettings.leo:

### newline-and-indent              !text = Tab  (The old binding, commented out, as you see)
indent-region                       !text = Tab
indent-region                       = ctrl-greater # Ctrl-shift->
unindent-region                     = ctrl-less # Ctrl-Shift-<
unindent-region                     = Shift-tab # Only when text is selected.

My apologies for the difficulties. We discussed them here, but that hardly matters.

Edward

gar

unread,
Nov 11, 2020, 1:43:48 AM11/11/20
to leo-e...@googlegroups.com
thanks, I'll try soon. What about those UI hangs? It seems like java's
garbage collector when you're using very old eclipse ide.
> --
> You received this message because you are subscribed to the Google Groups
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to leo-editor+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/leo-editor/CAMF8tS0uRuuS%2BXWpKKasSR4zmT-yxDawn-zTirm_pO9q7CgGUg%40mail.gmail.com.
>

gar

unread,
Nov 11, 2020, 1:54:12 AM11/11/20
to leo-e...@googlegroups.com
I applied  indent-region                       !text = Tab
now it works only in  myLeoSettings.leo, all the rest open tabs behave as before.

ср, 11 нояб. 2020 г. в 09:43, gar <gar...@gmail.com>:

gar

unread,
Nov 11, 2020, 2:00:25 AM11/11/20
to leo-e...@googlegroups.com
problem with indent is solved - there's left  newline-and-indent binding and it took precedence

Edward K. Ream

unread,
Nov 11, 2020, 5:36:30 AM11/11/20
to leo-editor
On Wed, Nov 11, 2020 at 1:00 AM gar <gar...@gmail.com> wrote:
problem with indent is solved - there's left  newline-and-indent binding and it took precedence

Glad to hear it.

Again, my apologies to longtime Leonistas. The improved key handling code required the change of settings. Imo, in the long term, the pain is justified. Newbies should not have your problem, because the defaults are correct.

Edward

gar

unread,
Nov 11, 2020, 5:53:40 AM11/11/20
to leo-e...@googlegroups.com
and what about the case when I want to indent the line cursor is currently on w/o selecting it all.
I can unindent it with shift-tab or ctrl-< - but their counterparts dont work.
this is a big concern for me.

Edward K. Ream

unread,
Nov 11, 2020, 8:17:52 AM11/11/20
to leo-e...@googlegroups.com
Wow. I can see your concern. The indent-body code has these lines:

# New in Leo 6.3.
if sel_1 == sel_2:
    c
.editCommands.selfInsertCommand(event)
   
return

This makes absolutely no sense to me. No unit tests fail without these lines, and without them indent-region works as expected with no selection range.

My guess, and it's a pure guess, is that the lines above were added sometime early during the key-handling project and then I forgot about them.

I'll create a new issue, and (probably a new branch), that merely removes those lines. In the meantime, try commenting them out yourself. Please report your results. Thanks.

Edward

Edward K. Ream

unread,
Nov 11, 2020, 8:28:06 AM11/11/20
to leo-editor
On Wednesday, November 11, 2020 at 7:17:52 AM UTC-6, Edward K. Ream wrote:

Wow. I can see your concern. The indent-body code has these lines:

# New in Leo 6.3.
if sel_1 == sel_2:
    c
.editCommands.selfInsertCommand(event)
   
return

I'll create a new issue, and (probably a new branch), that merely removes those lines.

Hmm. This might be a good time to replace c.updateBodyPane with the new undoer pattern using u.before/afterChangeBody. Indeed, the indent-region and unindent-region commands pass the evil preserveSel kwarg to c.updateBodyPane. That is, the new issue will be a good time to remove that kwarg and all its downstream complications. This is speculation at present. We shall see.

Edward

Edward K. Ream

unread,
Nov 11, 2020, 8:32:40 AM11/11/20
to leo-editor
On Wednesday, November 11, 2020 at 7:28:06 AM UTC-6, Edward K. Ream wrote:

> Hmm. This might be a good time to replace c.updateBodyPane with the new undoer pattern using u.before/afterChangeBody.

I meant to say, a good time to replace c.updateBodyPane in only the indent-region and unindent-region commands. No way am I going to get bogged down in general changes.

A quick cff shows that indeed only these two commands set preserveSel, so removing it from c.updateBodyPane should be dead easy.

Edward

Edward K. Ream

unread,
Nov 11, 2020, 8:41:06 AM11/11/20
to leo-editor
On Wednesday, November 11, 2020 at 7:17:52 AM UTC-6, Edward K. Ream wrote:

> I'll create a new issue...

Done. See #1729.

Edward

Edward K. Ream

unread,
Nov 11, 2020, 9:15:26 AM11/11/20
to leo-editor
On Wednesday, November 11, 2020 at 7:17:52 AM UTC-6, Edward K. Ream wrote:

The indent-body code has these lines:

# New in Leo 6.3.
if sel_1 == sel_2:
    c
.editCommands.selfInsertCommand(event)
   
return

This makes absolutely no sense to me.

Alas, auto-indentation does not happen without this ugly hack. I'll have to think carefully about possible solutions.

On a happier note, using u.before/afterChangeBody simplifies the indent/unindent-region commands. This work must be done in the ekr-undo branch, because the new methods do not yet exist in devel, or branches based on devel.

Edward

gar

unread,
Nov 11, 2020, 11:19:16 AM11/11/20
to leo-e...@googlegroups.com
# New in Leo 6.3.
if sel_1 == sel_2:
        c.editCommands.selfInsertCommand(event)
        return
In the meantime, try commenting them out yourself. Please report your results. Thanks.
did that. now can indent w/o selecting the whole line. technically it all works.
but since you've created an issue for that - i wish to ask you to pay attention to usability
now indenting also moves cursor somewhere around - but it is a good manner to preserve relative cursor position
when doing anything with text 

Edward K. Ream

unread,
Nov 11, 2020, 11:27:52 AM11/11/20
to leo-editor
On Wed, Nov 11, 2020 at 10:19 AM gar <gar...@gmail.com> wrote:

technically it all works. but since you've created an issue for that - i wish to ask you to pay attention to usability
now indenting also moves cursor somewhere around - but it is a good manner to preserve relative cursor position
when doing anything with text 

Thanks for the testing.

New code in the ekr-undo branch probably fixes the cursor problem, and more cleanly than before.

Alas, there was a reason for the ridiculous special case, as discussed in the issue. I'll have to give the code another think.

Edward
Reply all
Reply to author
Forward
0 new messages