Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-qtconsole for 
openSUSE:Factory checked in at 2021-02-01 13:27:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-qtconsole (Old)
 and      /work/SRC/openSUSE:Factory/.python-qtconsole.new.28504 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-qtconsole"

Mon Feb  1 13:27:40 2021 rev:15 rq:868157 version:5.0.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-qtconsole/python-qtconsole.changes        
2020-12-16 11:01:07.519607486 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-qtconsole.new.28504/python-qtconsole.changes 
    2021-02-01 13:29:40.390240279 +0100
@@ -1,0 +2,10 @@
+Sat Jan 30 20:21:58 UTC 2021 - Arun Persaud <a...@gmx.de>
+
+- specfile:
+  * update copyright year
+
+- update to version 5.0.2:
+  * Fix launching issue with Big Sur
+  * Remove partial prompt on copy
+
+-------------------------------------------------------------------

Old:
----
  qtconsole-5.0.1.tar.gz

New:
----
  qtconsole-5.0.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-qtconsole.spec ++++++
--- /var/tmp/diff_new_pack.fDS9u2/_old  2021-02-01 13:29:41.114241406 +0100
+++ /var/tmp/diff_new_pack.fDS9u2/_new  2021-02-01 13:29:41.118241413 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-qtconsole
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %define         skip_python2 1
 Name:           python-qtconsole
-Version:        5.0.1
+Version:        5.0.2
 Release:        0
 Summary:        Jupyter Qt console
 License:        BSD-3-Clause

++++++ qtconsole-5.0.1.tar.gz -> qtconsole-5.0.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qtconsole-5.0.1/PKG-INFO new/qtconsole-5.0.2/PKG-INFO
--- old/qtconsole-5.0.1/PKG-INFO        2020-11-24 18:27:25.000000000 +0100
+++ new/qtconsole-5.0.2/PKG-INFO        2021-01-21 18:30:43.370558000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: qtconsole
-Version: 5.0.1
+Version: 5.0.2
 Summary: Jupyter Qt console
 Home-page: http://jupyter.org
 Author: Jupyter Development Team
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qtconsole-5.0.1/docs/source/changelog.rst 
new/qtconsole-5.0.2/docs/source/changelog.rst
--- old/qtconsole-5.0.1/docs/source/changelog.rst       2020-11-24 
18:22:55.000000000 +0100
+++ new/qtconsole-5.0.2/docs/source/changelog.rst       2021-01-21 
18:24:15.000000000 +0100
@@ -8,6 +8,14 @@
 5.0
 ~~~
 
+5.0.2
+-----
+
+`5.0.2 on GitHub <https://github.com/jupyter/qtconsole/milestones/5.0.2>`__
+
+* Fix launching issue with Big Sur
+* Remove partial prompt on copy
+
 5.0.1
 -----
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qtconsole-5.0.1/qtconsole/_version.py 
new/qtconsole-5.0.2/qtconsole/_version.py
--- old/qtconsole-5.0.1/qtconsole/_version.py   2020-11-24 18:26:22.000000000 
+0100
+++ new/qtconsole-5.0.2/qtconsole/_version.py   2021-01-21 18:25:51.000000000 
+0100
@@ -1,2 +1,2 @@
-version_info = (5, 0, 1)
+version_info = (5, 0, 2)
 __version__ = '.'.join(map(str, version_info))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qtconsole-5.0.1/qtconsole/console_widget.py 
new/qtconsole-5.0.2/qtconsole/console_widget.py
--- old/qtconsole-5.0.1/qtconsole/console_widget.py     2020-11-21 
05:27:38.000000000 +0100
+++ new/qtconsole-5.0.2/qtconsole/console_widget.py     2021-01-21 
18:20:43.000000000 +0100
@@ -2176,35 +2176,55 @@
                 cursor.insertText(line)
             cursor.endEditBlock()
 
-    def _in_buffer(self, position=None):
-        """ Returns whether the current cursor (or, if specified, a position) 
is
-            inside the editing region.
+    def _in_buffer(self, position):
+        """ 
+        Returns whether the specified position is inside the editing region. 
+        """
+        return position == self._move_position_in_buffer(position)
+
+    def _move_position_in_buffer(self, position):
+        """ 
+        Return the next position in buffer.
         """
         cursor = self._control.textCursor()
-        if position is None:
-            position = cursor.position()
-        else:
-            cursor.setPosition(position)
+        cursor.setPosition(position)
         line = cursor.blockNumber()
         prompt_line = self._get_prompt_cursor().blockNumber()
         if line == prompt_line:
-            return position >= self._prompt_pos
-        elif line > prompt_line:
+            if position >= self._prompt_pos:
+                return position
+            return self._prompt_pos
+        if line > prompt_line:
             cursor.movePosition(QtGui.QTextCursor.StartOfBlock)
             prompt_pos = cursor.position() + len(self._continuation_prompt)
-            return position >= prompt_pos
-        return False
+            if position >= prompt_pos:
+                return position
+            return prompt_pos
+        return self._prompt_pos
 
     def _keep_cursor_in_buffer(self):
         """ Ensures that the cursor is inside the editing region. Returns
             whether the cursor was moved.
         """
-        moved = not self._in_buffer()
-        if moved:
-            cursor = self._control.textCursor()
+        cursor = self._control.textCursor()
+        endpos = cursor.selectionEnd()
+        if endpos < self._prompt_pos:
+            # Cursor is not in buffer, move to the end
             cursor.movePosition(QtGui.QTextCursor.End)
             self._control.setTextCursor(cursor)
-        return moved
+            return True
+
+        startpos = cursor.selectionStart()
+
+        new_endpos = self._move_position_in_buffer(endpos)
+        new_startpos = self._move_position_in_buffer(startpos)
+        if new_endpos == endpos and new_startpos == startpos:
+            return False
+
+        cursor.setPosition(new_startpos)
+        cursor.setPosition(new_endpos, QtGui.QTextCursor.KeepAnchor)
+        self._control.setTextCursor(cursor)
+        return True
 
     def _keyboard_quit(self):
         """ Cancels the current editing task ala Ctrl-G in Emacs.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qtconsole-5.0.1/qtconsole/frontend_widget.py 
new/qtconsole-5.0.2/qtconsole/frontend_widget.py
--- old/qtconsole-5.0.1/qtconsole/frontend_widget.py    2020-11-21 
05:27:38.000000000 +0100
+++ new/qtconsole-5.0.2/qtconsole/frontend_widget.py    2021-01-21 
18:20:43.000000000 +0100
@@ -215,11 +215,52 @@
         elif self._control.hasFocus():
             text = self._control.textCursor().selection().toPlainText()
             if text:
-                # Remove prompts.
-                lines = text.splitlines()
-                lines = map(self._highlighter.transform_classic_prompt, lines)
-                lines = map(self._highlighter.transform_ipy_prompt, lines)
-                text = '\n'.join(lines)
+                first_line_selection, *remaining_lines = text.splitlines()
+
+                # Get preceding text
+                cursor = self._control.textCursor()
+                cursor.setPosition(cursor.selectionStart())
+                cursor.setPosition(cursor.block().position(),
+                                   QtGui.QTextCursor.KeepAnchor)
+                preceding_text = cursor.selection().toPlainText()
+
+                def remove_prompts(line):
+                    """Remove all prompts from line."""
+                    line = self._highlighter.transform_classic_prompt(line)
+                    return self._highlighter.transform_ipy_prompt(line)
+
+                # Get first line promp len
+                first_line = preceding_text + first_line_selection
+                len_with_prompt = len(first_line)
+                first_line = remove_prompts(first_line)
+                prompt_len = len_with_prompt - len(first_line)
+
+                # Remove not selected part
+                if prompt_len < len(preceding_text):
+                    first_line = first_line[len(preceding_text) - prompt_len:]
+
+                # Remove partial prompt last line
+                if len(remaining_lines) > 0 and remaining_lines[-1]:
+                    cursor = self._control.textCursor()
+                    cursor.setPosition(cursor.selectionEnd())
+                    block = cursor.block()
+                    start_pos = block.position()
+                    length = block.length()
+                    cursor.setPosition(start_pos)
+                    cursor.setPosition(start_pos + length - 1,
+                                       QtGui.QTextCursor.KeepAnchor)
+                    last_line_full = cursor.selection().toPlainText()
+                    prompt_len = (
+                        len(last_line_full)
+                        - len(remove_prompts(last_line_full)))
+                    if len(remaining_lines[-1]) < prompt_len:
+                        # This is a partial prompt
+                        remaining_lines[-1] = ""
+
+                # Remove prompts for other lines.
+                remaining_lines = map(remove_prompts, remaining_lines)
+                text = '\n'.join([first_line, *remaining_lines])
+
                 # Needed to prevent errors when copying the prompt.
                 # See issue 264
                 try:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qtconsole-5.0.1/qtconsole/qtconsoleapp.py 
new/qtconsole-5.0.2/qtconsole/qtconsoleapp.py
--- old/qtconsole-5.0.1/qtconsole/qtconsoleapp.py       2020-11-21 
05:27:38.000000000 +0100
+++ new/qtconsole-5.0.2/qtconsole/qtconsoleapp.py       2021-01-21 
18:20:43.000000000 +0100
@@ -7,6 +7,7 @@
 # Copyright (c) Jupyter Development Team.
 # Distributed under the terms of the Modified BSD License.
 
+from distutils.version import LooseVersion
 import os
 import signal
 import sys
@@ -57,7 +58,7 @@
     except AttributeError:
         pass
 
-from qtpy import QtCore, QtGui, QtWidgets
+from qtpy import QtCore, QtGui, QtWidgets, QT_VERSION
 
 from traitlets.config.application import boolean_flag
 from traitlets.config.application import catch_config_error
@@ -410,6 +411,10 @@
 
     @catch_config_error
     def initialize(self, argv=None):
+        # Fixes launching issues with Big Sur
+        # https://bugreports.qt.io/browse/QTBUG-87014, fixed in qt 5.15.2
+        if sys.platform == 'darwin' and LooseVersion(QT_VERSION) < 
LooseVersion('5.15.2'):
+            os.environ['QT_MAC_WANTS_LAYER'] = '1'
         self._init_asyncio_patch()
         self.init_qt_app()
         super().initialize(argv)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/qtconsole-5.0.1/qtconsole/tests/test_jupyter_widget.py 
new/qtconsole-5.0.2/qtconsole/tests/test_jupyter_widget.py
--- old/qtconsole-5.0.1/qtconsole/tests/test_jupyter_widget.py  2020-11-21 
23:57:26.000000000 +0100
+++ new/qtconsole-5.0.2/qtconsole/tests/test_jupyter_widget.py  2021-01-21 
18:20:43.000000000 +0100
@@ -2,7 +2,7 @@
 import sys
 
 import pytest
-from qtpy import QtWidgets
+from qtpy import QtWidgets, QtGui
 
 from qtconsole.client import QtKernelClient
 from qtconsole.jupyter_widget import JupyterWidget
@@ -82,3 +82,28 @@
             '<p style="-qt-paragraph-type:empty; margin-top:0px; 
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; 
text-indent:0px;"><br /></p>\n'
             '<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; 
margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" 
color:#000080;">In [</span><span style=" font-weight:600; 
color:#000080;">2</span><span style=" color:#000080;">]:</span> 
</p></body></html>'
         ))
+
+    def test_copy_paste_prompt(self):
+        """Test copy/paste removes partial and full prompts."""
+        w = JupyterWidget(kind='rich')
+        w._show_interpreter_prompt(1)
+        control = w._control
+
+        code = "    if True:\n        print('a')"
+        w._set_input_buffer(code)
+        assert code not in control.toPlainText()
+
+        cursor = w._get_prompt_cursor()
+
+        pos = cursor.position()
+        cursor.setPosition(pos - 3)
+        cursor.movePosition(QtGui.QTextCursor.End,
+                            QtGui.QTextCursor.KeepAnchor)
+        control.setTextCursor(cursor)
+        control.hasFocus = lambda: True
+        w.copy()
+        clipboard = QtWidgets.QApplication.clipboard()
+        assert clipboard.text() == code
+        w.paste()
+        expected = "In [1]: if True:\n   ...:     print('a')"
+        assert expected in control.toPlainText()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/qtconsole-5.0.1/qtconsole.egg-info/PKG-INFO 
new/qtconsole-5.0.2/qtconsole.egg-info/PKG-INFO
--- old/qtconsole-5.0.1/qtconsole.egg-info/PKG-INFO     2020-11-24 
18:27:23.000000000 +0100
+++ new/qtconsole-5.0.2/qtconsole.egg-info/PKG-INFO     2021-01-21 
18:30:40.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: qtconsole
-Version: 5.0.1
+Version: 5.0.2
 Summary: Jupyter Qt console
 Home-page: http://jupyter.org
 Author: Jupyter Development Team

Reply via email to