Old "Extract section" and new "extract" commands are different

10 views
Skip to first unread message

vitalije

unread,
Feb 27, 2012, 3:14:53 PM2/27/12
to leo-e...@googlegroups.com
A long time ago in Leo there were two commands with similar effect extract-section and extract-method. Then they were replaced with the extract command. When extracting method or function that is included by @others directive everything is working as it should. But when for example one want to extract section that is indented then reference line <<section name>>, after extraction, is moved to the beginning of line. I would expect that the section reference should stay where it was before extraction, i.e. indented.

Searching in Leo's source I have found what should be changed.

Code-->Core classes-->@file leoCommands.py-->class commands-->Command handlers...-->Edit Menu...-->Edit Body submenu-->c.extract...-->extract & helpers : line 29 is

h,b,middle = ref_h,lines[1:],lines[0]

but should be (IMHO):


h,b,middle = ref_h, lines[1:], ' ' * ws +lines[0]


ws is calculated before and it is number of spaces before section reference line

I hope this would eventually be changed in future versions of Leo.

Vitalije

Edward K. Ream

unread,
Feb 27, 2012, 6:52:49 PM2/27/12
to leo-editor


On Feb 27, 2:14 pm, vitalije <vitali...@gmail.com> wrote:
> A long time ago in Leo there were two commands with similar effect
> extract-section and extract-method. Then they were replaced with the
> extract command. When extracting method or function that is included by
> @others directive everything is working as it should. But when for example
> one want to extract section that is indented then reference line <<section
> name>>, after extraction, is moved to the beginning of line. I would expect
> that the section reference should stay where it was before extraction, i.e.
> indented.
>
> Searching in Leo's source I have found what should be changed.

Thanks for this. Rev 5035 changes c.extract as you suggest.

All unit tests pass, including two tests that were adjusted to take
into account the new operation.

Edward
Reply all
Reply to author
Forward
0 new messages