Commits

Yuya Nishihara  committed d4fc350

cmdui: make sure newly-opened prompt line is visible (fixes #42)

Because scintilla delays line wrapping, it should re-scroll on painted
notification.

> To scroll to the position correctly, delay the scroll until the wrapping
> has been performed by waiting for an initial SCN_PAINTED notification.

(from http://www.scintilla.org/ScintillaDoc.html#LineWrapping)

  • Participants
  • Parent commits eb514f9
  • Branches stable

Comments (0)

Files changed (1)

File tortoisehg/hgqt/cmdui.py

         self.setCursorPosition(self.lines() - 1, len(self._prompt))
         self.setReadOnly(False)
 
+        # make sure the prompt line is visible. Because QsciScintilla may
+        # delay line wrapping, setCursorPosition() doesn't always scrolls
+        # to the correct position.
+        # http://www.scintilla.org/ScintillaDoc.html#LineWrapping
+        self.SCN_PAINTED.connect(self._scrollCaretOnPainted)
+
+    @pyqtSlot()
+    def _scrollCaretOnPainted(self):
+        self.SCN_PAINTED.disconnect(self._scrollCaretOnPainted)
+        self.SendScintilla(self.SCI_SCROLLCARET)
+
     @pyqtSlot()
     def closePrompt(self):
         """Disable user input"""