Copy/Paste into abbreviations weirdness

48 views
Skip to first unread message

Rob

unread,
Jul 26, 2018, 9:12:43 PM7/26/18
to leo-editor
Suppose a simple abbreviation such as:

h1;;=<h1><|HEADING1|></h1>

  1. Suppose next that we copy some text to the clipboard, such as `This is a heading.`
  2. Invoke the abbreviation, which highlights the text `HEADING1`.
  3. Try pasting the clipboard text (CTRL-V in Windows or CMD-V on MacOS).
  4. The current devel builds leave `HEADING1` in place.
  5. Earlier builds pasted the clipboard text into the abbreviation placeholder.
I don't know exactly in which devel build this behavior changed. However, I do know that this build worked as expected (clipboard text pasted into placeholder):

Leo 5.7.4 devel, build 20180607085129, Thu Jun 7 08:51:29 CDT 2018


The current builds (last several weeks, at least) exhibit the new behavior. So apparently, sometime between early June and mid-July this changed.

Just wondering, was this change intentional (feature) or not (bug). For me, it's annoying and I would prefer the previous behavior, as pasting the placeholder text serves no useful purpose.

If this is a bug, I can file on the GitHub issue tracker.

Rob...

Terry Brown

unread,
Jul 26, 2018, 11:35:02 PM7/26/18
to Leo list
Ish - I see this in 4d23cbb5, but there's a block of commits which crash on load with current (vestigial) cache, making it hard to use git bisect.

I guess a clean ~/.leo should work...

so running git bisect and launching Leo like this:

rm -rf /tmp/.leo ; HOME=/tmp python3 /home/tbrown/t/Package/leo/git/leo-editor/launchLeo.py --no-splash 

I get

43a2672b59d107e9be6a7d812735736b4850eefc is the first bad commit
commit 43a2672b59d107e9be6a7d812735736b4850eefc
Author: Edward K. Ream <edre...@gmail.com>
Date:   Sun Jul 8 03:49:19 2018 -0500

    Fixed #933 and improved other aspects of clipboard handling:
    
    - LM.openEmptyWorkBook now saves/restores clipboard.
    - Deleted qt_gui.setClipboardSelection.
      It is now a synonym for replaceClipboardWith.
    - qtew.setSelectionRange now sets the selection only if there is selected text.

To see the bug Rob's describing, even with an empty ~/.leo:

 - start Leo
 - start editing body
 - copy some text to the clipboard
 - type html;;
 - you should see an html template with `title` selected
 - Ctrl-V, should place the text you copied above, but from 43a2672 on wards simple deselects
   `title`, suggesting `title` was the content of the clipboard.  Which suggests selection is copying
   to clipboard now.

Cheers -Terry



--
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 post to this group, send email to leo-e...@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

vitalije

unread,
Jul 27, 2018, 3:57:47 AM7/27/18
to leo-e...@googlegroups.com
I saw this behavior recently but I thought it might have something to do with my machine.

Rev  0eab277bfdd should fix this. It was just that one flag was set to True instead to False.

The flag is "middleButton" and it seems that the intent was to simulate on Windows middle button pasting feature of Linux. This feature is quite useful and I miss it a lot lately. It would be great if it can be simulated on Windows too, but the current implementation doesn't seem to work properly. So changing this flag to False solved the issue.

Vitalije


Rob

unread,
Jul 27, 2018, 8:58:11 AM7/27/18
to leo-editor
Just updated to latest in devel branch and it's still pasting the placeholder text instead of clipboard.

Rob...

Terry Brown

unread,
Jul 27, 2018, 12:37:10 PM7/27/18
to Leo list
Try 5ff9a7f3e5

Cheers -Terry

Terry Brown

unread,
Jul 27, 2018, 12:41:43 PM7/27/18
to Leo list
Your change didn't seem to fix the bug Rob reported, so I reverted it "just because" :-)  I'm not sure that kwarg really does anything at all.

I run this code from a @script to get middle button pasting in Windows.

# monkey patch to give Leo body widget X11 like select->copy and
# middle-button->paste behaviors in Windows, run it from a @script
# node with @bool scripting-at-script-nodes = True

from leo.core.leoQt import QtCore, QtWidgets
from leo.plugins.qt_text import QTextEditWrapper

old = QTextEditWrapper.set_signals

def set_signals(self, old=old):

    old(self)

    def new_selection(w=self.widget):
        sel = w.textCursor().selectedText()
        but = QtWidgets.QApplication.mouseButtons() & QtCore.Qt.LeftButton
        if sel and but:
            sel = sel.replace(u'\u2029', '\n')
            QtWidgets.QApplication.clipboard().setText(sel)

    def middle_click(event, w=self.widget, old=self.widget.mouseReleaseEvent):
        if not event.button() == QtCore.Qt.MiddleButton:
            return old(event)
        cursor = w.cursorForPosition(event.pos())
        w.copy()  # copy selection to clipboard if not there already
        text = QtWidgets.QApplication.clipboard().text()
        cursor.insertText(text)
        w.setTextCursor(cursor)

    self.widget.selectionChanged.connect(new_selection)
    self.widget.mouseReleaseEvent = middle_click

QTextEditWrapper.set_signals = set_signals
c.frame.body.wrapper.set_signals()


On Fri, Jul 27, 2018 at 2:57 AM vitalije <vita...@gmail.com> wrote:
I saw this behavior recently but I thought it might have something with my machine.

Rev  0eab277bfdd should fix this. It was just that one flag was set to True instead to False.

The flag is "middleButton" and it seems that the intent was to simulate on Windows middle button pasting feature of Linux. This feature is quite useful and I miss it a lot lately. It would be great if it can be simulated on Windows too, but the current implementation doesn't seem to work properly. So changing this flag to False solved the issue.

Vitalije

Rob

unread,
Jul 27, 2018, 1:40:00 PM7/27/18
to leo-editor
Thanks, Terry! That did the trick.

Rob...

On Friday, July 27, 2018 at 12:37:10 PM UTC-4, Terry Brown wrote:
Try 5ff9a7f3e5


Edward K. Ream

unread,
Jul 28, 2018, 7:52:57 AM7/28/18
to leo-editor
On Friday, July 27, 2018 at 12:40:00 PM UTC-5, Rob wrote:

Thanks, Terry! That did the trick.

Thanks, Terry and Vitalije for this work.

Here, I agree with Vitalije that the kwarg does more harm than good. Duplicating code to do exactly what is wanted in each place/situation is/would be a good idea.

Edward
Reply all
Reply to author
Forward
0 new messages