Skip to content

Commit

Permalink
Merge pull request spyder-ide#23316 from ccordoba12/issue-23313
Browse files Browse the repository at this point in the history
PR: Prevent Chinese input method to block edit input area
  • Loading branch information
ccordoba12 authored Dec 19, 2024
2 parents 49e81ef + ceb7edd commit 3f64ee3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spyder/plugins/ipythonconsole/widgets/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def __init__(self, parent=None):
# To not use Spyder calltips obtained through the monitor
self.calltips = False

# ---- Public methods ----------------------------------------------------
# ---- Public methods
# -------------------------------------------------------------------------
def insert_horizontal_ruler(self):
"""
Insert a horizontal ruler with the appropriate color according
Expand All @@ -69,7 +70,8 @@ def insert_horizontal_ruler(self):
cursor.movePosition(cursor.End)
cursor.insertFrame(ruler)

# ---- Private methods ---------------------------------------------------
# ---- Private methods
# -------------------------------------------------------------------------
def _key_paren_left(self, text):
""" Action for '(' """
self.current_prompt_pos = self.parentWidget()._prompt_pos
Expand All @@ -79,7 +81,8 @@ def _key_paren_left(self, text):
self.show_object_info(last_obj)
self.insert_text(text)

# ---- Qt methods --------------------------------------------------------
# ---- Qt methods
# -------------------------------------------------------------------------
def showEvent(self, event):
"""Reimplement Qt Method"""
self.sig_visibility_changed.emit(True)
Expand Down
22 changes: 22 additions & 0 deletions spyder/widgets/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,28 @@ def mouseDoubleClickEvent(self, event):
elif isinstance(self, QTextEdit):
QTextEdit.mouseDoubleClickEvent(self, event)

def inputMethodQuery(self, query):
"""
Prevent Chinese input method to block edit input area.
Notes
-----
This was suggested by a user in spyder-ide/spyder#23313. So, it's not
tested by us.
"""
if query == Qt.ImInputItemClipRectangle:
cursor_rect = self.cursorRect()
margins = self.viewportMargins()
cursor_rect.moveTopLeft(
cursor_rect.topLeft() + QPoint(margins.left(), margins.top())
)
return cursor_rect

if isinstance(self, QPlainTextEdit):
QPlainTextEdit.inputMethodQuery(self, query)
elif isinstance(self, QTextEdit):
QTextEdit.inputMethodQuery(self, query)


class TracebackLinksMixin(object):
"""Mixin to make file names in tracebacks and anchors clickable."""
Expand Down

0 comments on commit 3f64ee3

Please sign in to comment.