partial chunk selection

70 views
Skip to first unread message

Steve Borho

unread,
Jan 8, 2013, 11:36:48 PM1/8/13
to thg...@googlegroups.com
My current plan is to stop development on change selection once the display mode has a toggle, and switch over to testing and documentation for the new feature in preparation for 2.7.

Thinking ahead to later releases, I think we will need to support the amend command with partial commit, and I also have a plan for supporting partial chunk selection.

'partial chunk selection' is the process of removing lines from a diff chunk.  The most common use-case is where you have added multiple class methods next to each other in a file, and those all are merged into a single diff chunk and you would prefer to exclude one or more of those functions.

The way I envision supporting partial chunk selection is via Qsci text selection.  When the fileview context menu is opened and a selection is active and we are in change selection diff mode, we check whether the line range covered by the selection falls within a single diff chunk and all of the lines are either deletion (-) or addition (+) lines.  When all of those conditions are met, we add a context menu option labeled: "Exclude selected range from commit".  When this menu option is activated, we add a 'striked' list to the diff chunk object and strike-through those lines in the QSci using a StrikeIndicator.

On commit, the striked addition lines are omitted from the patch file and the striked deletion lines are turned into context lines.

Whenever a chunk's exclusion state is toggled, its striked list is emptied (resetting the selection, this makes the various check status events functional again).  If any of the file's diff chunks have striked lists, the file is considered to be partially selected (requiring the patch path).

--
Steve Borho

Angel Ezquerra

unread,
Jan 9, 2013, 3:23:08 AM1/9/13
to thg...@googlegroups.com
This is _very_ exciting and something I've wished we had for a long time!

I think the way you describe this working is great if slightly
undiscoverable. Maybe we could show a tooltip or status message
whenever the user selects some text that meets the "partial chunk"
requirements, saying "right click to exclude lines from commit" or
something similar?

Another option would be to add a toggle button, which toggles the
"exclude mode", which would let you add margin markers (such as those
that you can add in Notepad++) to select the lines that should be
excluded...

Cheers,

Angel

Steve Borho

unread,
Jan 10, 2013, 3:34:14 PM1/10/13
to thg...@googlegroups.com
thg hacking is kind of fun at the moment, no?  What's somewhat sad is how little code was actually required in partialcommit.py.  If I had realized it would be that easy we could have done this ages ago.
  
I think the way you describe this working is great if slightly
undiscoverable. Maybe we could show a tooltip or status message
whenever the user selects some text that meets the "partial chunk"
requirements, saying "right click to exclude lines from commit" or
something similar?

Yeah, perhaps.

Another option would be to add a toggle button, which toggles the
"exclude mode", which would let you add margin markers (such as those
that you can add in Notepad++) to select the lines that should be
excluded...

How about this:  when a Qsci selection is active and the user clicks on the change selection / folding margin on a line within the selection, we toggle the striked state for the selected lines.

I also think we'll be able to capture the selection changed signal and move the selection start point to ensure the selection always starts in col 0 of the start line.  This will be a visual clue that you are selecting lines of the diff, and not just arbitrary text.

--
Steve Borho

Angel Ezquerra

unread,
Jan 10, 2013, 7:27:03 PM1/10/13
to thg...@googlegroups.com
Definitelly! :-)

> What's somewhat sad is how
> little code was actually required in partialcommit.py. If I had realized it
> would be that easy we could have done this ages ago.

As is often the case, thinks usually seem simpler in hindsight. Don't
kick yourself too much about this!

>> I think the way you describe this working is great if slightly
>> undiscoverable. Maybe we could show a tooltip or status message
>> whenever the user selects some text that meets the "partial chunk"
>> requirements, saying "right click to exclude lines from commit" or
>> something similar?
>
>
> Yeah, perhaps.
>
>> Another option would be to add a toggle button, which toggles the
>> "exclude mode", which would let you add margin markers (such as those
>> that you can add in Notepad++) to select the lines that should be
>> excluded...
>
>
> How about this: when a Qsci selection is active and the user clicks on the
> change selection / folding margin on a line within the selection, we toggle
> the striked state for the selected lines.
>
> I also think we'll be able to capture the selection changed signal and move
> the selection start point to ensure the selection always starts in col 0 of
> the start line. This will be a visual clue that you are selecting lines of
> the diff, and not just arbitrary text.

I think the trick will be in making sure that the user can tell at a
glance when he can toggle individual lines and when he wont.

For example we could stop the selection from going beyond the line at
which point it is no longer possible to do a partial chunk selection.
That is, the user starts selecting on a line (I assume full lines will
be always selected). The user drags the mouse down a few lines which
could be partially selected, and the selection follows his mouse. The
user keeps going down until it reaches a line that could not be
partially selected with the rest, at which point the selection gets
"stuck" at the last valid line, even if the mouse is still clicked and
keeps going down. If the user moves the mouse back up (without
releasing the button) and reaches the bottom of the "splittable area"
the selection starts to follow the mouse again.

I don't know if this is feasible with QT, but I think it could work.
What I don't know is if my explanation can be understood by anybody
other than myself :-P

Cheers,

Angel

Johan Samyn

unread,
Jan 12, 2013, 5:18:34 AM1/12/13
to thg...@googlegroups.com, Steve Borho
Maybe doubleclick, to avoid accidently toggling the status of those lines, or do you find that too cumbersome ?

And what about an extra margin like in some editors and gui debuggers, where user can click next to a line to toggle the state of that particular line ? (yes, not dblclick this time, cause of smaller zone, so less likely to happen)



I also think we'll be able to capture the selection changed signal and move the selection start point to ensure the selection always starts in col 0 of the start line.  This will be a visual clue that you are selecting lines of the diff, and not just arbitrary text.

--
Steve Borho


-- 
________________________________________________________________________
"Perfection seems to be achieved, not when there is nothing more to add,
but when there is nothing left to take away." - A. de Saint-Exupéry

Andreas Tscharner

unread,
Jan 13, 2013, 5:05:12 AM1/13/13
to thg...@googlegroups.com
On 09.01.2013 05:36, Steve Borho wrote:
[snip]
> Thinking ahead to later releases, I think we will need to support the
> amend command with partial commit, and I also have a plan for supporting
> partial chunk selection.

Will the shelve tool/window also use the new "partial commit" style?

Best regards
Andreas
--
Andreas Tscharner sterne...@gmail.com
------------------------------------------------------------------------
Der entscheidende Vorteil eines Chats gegenueber einem normalen Telefon-
anruf ist der, dass ersterer langsamer geht und mehr kostet (fuer den
lebenswichtigen Austausch von Informationen wie "hya folks", "C U
l8er" und ":-)") ... Aus Murphy's Computergesetzen

Steve Borho

unread,
Jan 13, 2013, 10:28:37 PM1/13/13
to thg...@googlegroups.com



2013/1/13 Andreas Tscharner <sterne...@gmail.com>

On 09.01.2013 05:36, Steve Borho wrote:
[snip]

Thinking ahead to later releases, I think we will need to support the
amend command with partial commit, and I also have a plan for supporting
partial chunk selection.

Will the shelve tool/window also use the new "partial commit" style?

The chunk view could use the same margin pixmaps as we eventually use for the non-folded mode. 

--
Steve Borho
Reply all
Reply to author
Forward
0 new messages