After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 81880 - Pasting a text selection by clicking the middle mouse button doesn't position the text cursor behind the inserted text.
Pasting a text selection by clicking the middle mouse button doesn't position...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.0.x
Other Linux
: Normal normal
: Medium fix
Assigned To: gtk-bugs
gtk-bugs
: 90608 127705 334467 631195 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-05-15 16:54 UTC by Evert Verhellen
Modified: 2018-05-02 13:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (2.35 KB, patch)
2004-02-26 16:07 UTC, Paolo Borelli
needs-work Details | Review
Place the cursor after the paste has been done (1.42 KB, patch)
2009-11-14 17:30 UTC, Emmanuel Rodriguez
none Details | Review

Description Evert Verhellen 2002-05-15 16:54:33 UTC
Description of Problem:
Pasting a text selection by clicking the middle mouse button should
position the text cursor right behind the inserted text in order to be able
to continue typing.

Steps to reproduce the problem:
1. Start gedit2.
2. Type in the following text (do no type the line numbers):

   1 One Two Three
   2 Four Five Six

3. Select "One ".

   1 [One ]Two Three
   2 Four Five Six

4. Click the middle mouse button in front of the word "Five".

   1 [One ]Two Three
   2 Four One Five Six

Actual Results:
The text selection is pasted correctly. The text cursor is still behind the
text selection (although invisible).

Expected Results:
The text cursor should be positioned behind the inserted text in order to
be able to continue typing.

5. Press [space].

Actual Results:
The text selection "One " on the 1st line is erased and replaced with a blank.

Expected Results:
The text selection "One " on the 1st line should be cancelled and a blank
should be inserted behind the inserted "One " on the 2nd line.

How often does this happen?
Always.

Additional Information:
This would make gedit2 have the same middle mouse button behaviour as NEdit.

Version Details:
gtk2-2.0.2.0.200205130458-0.snap.ximian.1
gedit2-1.118.0.0.200205130458-0.snap.ximian.1
Comment 1 Havoc Pennington 2002-10-11 22:20:48 UTC
Basically a UI decision. I don't know the answer offhand.
Comment 2 Calum Benson 2002-10-21 17:41:51 UTC
The current behaviour certainly seems broken, especially the text
cursor disappearing altogether at one point.  

I haven't really played with this, but my first reaction would be that
selecting text and pasting it somewhere with the middle mouse button
should leave you in exactly the same state as selecting the text,
hitting Ctrl+C, moving the cursor to the insertion point and hitting
Ctrl+V.
Comment 3 Rodd Clarkson 2002-10-22 00:26:52 UTC
I assume you're suggesting that the selected text should remain
selected, but that the cursor focus should move to where the paste
occurred.

If this is the case, the I agree.  This would allow you to continue
pasting using the middle mouse button, but also save the hassel of
having to click again to continue working at the point of paste.

Looking at my own work patterns (and I'm sure I'm not unique in this)
you typically paste text to where you are currently working and not
from where you are currently working to another area.  Thus, it would
make good UI sense to have the cursor follow the paste.

Also, with the current behavior, if the selection comes from another
window, then you have to focus the window to continue working in it. 
For example, if you select a command from a web page, and then middle
click paste it the terminal you then have to focus the window to run
the command.  Having the cursor focus follow paste would alleviate
this issue.





Comment 4 Evert Verhellen 2002-10-22 16:29:22 UTC
Rodd, your comments reflect exactly what was meant. The cursor focus
should go to where the text paste occured. Your multiple-window
example shows that the current implementation behaves inconsistently.

Additional Information:
The text widgets in Mozilla have the same middle mouse button
behaviour as NEdit. They allow the user to continue typing where the
text paste occured.
Comment 5 Evert Verhellen 2002-11-14 23:43:42 UTC
I have some additional information. As a result of this problem,
pasting a text selection at the end of a document by clicking the
middle mouse button *will not* display the end of the document. On the
other hand, pasting a text selection at the end of a document with
either [Ctrl]+[V] or [Shift]+[Insert] *will* display the end of the
document.
Comment 6 Calum Benson 2002-12-13 17:42:07 UTC
*** Bug 90608 has been marked as a duplicate of this bug. ***
Comment 7 Rodd Clarkson 2002-12-16 22:31:18 UTC
I'd urge everyone to go and read bug 90608 as it's not so much a
duplicate of this bug, but an extension (IMHO).

bug 90608 discusses that fact that middle clicking at the end of a
selection seems to replace the current selection, instead of pasting
the selection at the end of the current selection.

Comment 8 Paolo Maggi 2004-02-26 11:07:37 UTC
*** Bug 127705 has been marked as a duplicate of this bug. ***
Comment 9 Paolo Borelli 2004-02-26 16:06:07 UTC
The following patch seems to fix it:

in gtktextbuffer during pre_paste_prep we move the "insert" mark at
the insertion point

in gtktextview after having pasted the text we retrieve the "insert"
mark and move the cursor to it making sure of also scroll the window
if needed.

(note that we cannot simply move the cursor to the iter retrieved at
the button click because the clipboard would be emptied)
Comment 10 Paolo Borelli 2004-02-26 16:07:00 UTC
Created attachment 24811 [details] [review]
proposed patch
Comment 11 Rodd Clarkson 2004-02-27 01:34:36 UTC
I presume this is to fix both gtk+-2.2.5 and gtk+-HEAD?
Comment 12 Paolo Borelli 2004-02-27 07:32:35 UTC
the patch is against HEAD, dunno about 2.2... I presume that it should
apply there too.
Comment 13 Owen Taylor 2004-03-13 15:34:55 UTC
This patch really makes no sense to me - the two changes are:

 A) Before inserting the text, we move the "insert" mark
    (just one end of the selection) to the new insertion
    point.

 B) After we request the text, we move both ends of the
    selection to the the "insert" mark.

Note that these two steps can occur in either order, depending
on whether the paste is from the same process or from a 
different process. 

I don't see how this is going to work in the case where B)
happens first. And with a little testing, in fact, the results
in the remote case are in fact incorrect.

I'm going to revert the patch, and reopen and move to the
2.4.1 milestone.
Comment 14 Matthias Clasen 2004-03-13 20:09:06 UTC
Ugh, sorry. My testing seemed to indicate that it works. Maybe the
testing was too superficial...
Comment 15 Luis Villa 2004-04-29 15:52:58 UTC
Comment on attachment 24811 [details] [review]
proposed patch

Needs-work based on owen's comment.
Comment 16 Elijah Newren 2004-06-19 18:43:16 UTC
Mass changing gtk+ bugs with target milestone of 2.4.2 to target 2.4.4, as
Matthias said he was trying to do himself on IRC and was asking for help with. 
If you see this message, it means I was successful at fixing the borken-ness in
bugzilla :)  Sorry for the spam; just query on this message and delete all
emails you get with this message, since there will probably be a lot.
Comment 17 Emmanuel Rodriguez 2009-11-09 13:20:25 UTC
Has this bug been forgotten? The current behavior is a bit annoying specially when pasting into a different "screen page" as the view scrolls back to the cursor.
Comment 18 Emmanuel Rodriguez 2009-11-14 17:30:03 UTC
Created attachment 147736 [details] [review]
Place the cursor after the paste has been done

This patch places the cursor at the location where the past has been done as soon as the paste event is finished. This seems to be the best place where to change the position as the paste event is asynchronous.
Comment 19 Rodd Clarkson 2009-11-15 10:15:57 UTC
Question.  Does still allow for multiple pastes of the highlighted text?
Comment 20 Emmanuel Rodriguez 2009-11-15 14:39:35 UTC
> Question.  Does still allow for multiple pastes of the highlighted text?
This patch allows exactly what the existing implementation of GtkTextView does. As long as the highlighted text comes from another application there will be no problem.

Currently GtkTextView doesn't allow highlighted text from the same buffer to be copy pasted more than once because the paste operation unselects the highlighted text and the text is not stored in the clipboard. I believe that this is a separate bug.
Comment 21 Sébastien Wilmet 2013-04-06 16:22:26 UTC
*** Bug 631195 has been marked as a duplicate of this bug. ***
Comment 22 Daniel Boles 2017-09-14 10:20:38 UTC
*** Bug 334467 has been marked as a duplicate of this bug. ***
Comment 23 GNOME Infrastructure Team 2018-05-02 13:40:32 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/220.