On Wed, Mar 11, 2020 at 03:48:04PM -0400, Richard Kimberly Heck wrote: > On 3/11/20 3:12 PM, Jean-Marc Lasgouttes wrote: > > Le 11/03/2020 à 19:14, Scott Kostyshak a écrit : > >> commit adb7283b69f5dddfabb8d807a432cd1e5e60b221 > >> Author: Scott Kostyshak <skost...@lyx.org> > >> Date: Wed Mar 11 14:18:33 2020 -0400 > >> > >> outline-up/down: preserve cursor's position > >> There is no need to change the cursor's position to the > >> beginning of > >> the line. > >> This change does not affect the behavior of using the > >> buttons in the > >> Outliner pane, but is useful for using the keyboard shortcuts. > > > > What is the difference between the two code paths? > > One has OutlineUp and one has OutlineDown?
I'm glad I'm not the only one that originally interpretted JMarc's comment like that. I made a patch thinking he was hinting that I should combine the code to reduce duplication. See attached. Now I realize that's not what he was trying to say, and I'm not sure the patch actually makes things more clear. I now realize he was referring to my commit message that the change does not affect behavior in the Outliner pane. Regarding that interpretation, if you click on a section in the outline, the cursor is automatically moved to position 0 which makes sense in my opinion. Also, if you place the cursor yourself in a section and then just click on the down arrow, the cursor position is still moved to position 0. I'm not sure where this latter behavior happens. I could take a look if we wanted to consider removing it. Note that TocWidget.cpp still ends up calling the LFUN handled by Text3 (i.e., the code touched by this commit), but I guess the positioning is done before or after. I'm happy to look into this further if I know what the ideal behavior would be. Scott
From b8325233dcda6bed4e6f45f415447cde373f9619 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak <skost...@lyx.org> Date: Wed, 11 Mar 2020 15:44:14 -0400 Subject: [PATCH] Reduce duplication of code --- src/Text3.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index eef24a7d6b..236a06868e 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -2812,17 +2812,15 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; case LFUN_OUTLINE_DOWN: - outline(OutlineDown, cur, this); + case LFUN_OUTLINE_IN: { + OutlineOp const direction = cmd.action() == LFUN_OUTLINE_UP ? + OutlineUp : OutlineDown; + outline(direction, cur, this); setCursor(cur, cur.pit(), cur.pos()); cur.forceBufferUpdate(); needsUpdate = true; break; - - case LFUN_OUTLINE_IN: - outline(OutlineIn, cur, this); - cur.forceBufferUpdate(); - needsUpdate = true; - break; + } case LFUN_OUTLINE_OUT: outline(OutlineOut, cur, this); -- 2.20.1
signature.asc
Description: PGP signature
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel