Commit 71ae0085 authored by minicom's avatar minicom
Browse files

fix IME bug

(cherry picked from commit 0f3704e79b481c9e579a73b016609ace17ae058f)
parent 4b78bb4e
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -190,20 +190,9 @@ class SourceTextEdit(QTextEdit):
                    added_text = self.input_method_text
                    change_from = self.input_method_from
                    input_method_used = True
                    self.input_method_from = -1
                elif self.change_added > 0:
                    text = self.toPlainText()
                    len_text = len(text)
                    cursor = self.textCursor()
                    
                    if self.change_added >  len_text or change_from + self.change_added > len_text:
                        self.change_added = 1
                        change_from = self.textCursor().position() - 1
                        cursor.setPosition(change_from)
                        cursor.setPosition(change_from + self.change_added, QTextCursor.MoveMode.KeepAnchor)
                        added_text = cursor.selectedText()
                        if added_text == '' or added_text == '':
                                self.change_added = 2
                                change_from -= 1
                    cursor.setPosition(change_from)
                    cursor.setPosition(change_from + self.change_added, QTextCursor.MoveMode.KeepAnchor) 
                    added_text = cursor.selectedText()
+3 −19
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class TextBlkItem(QGraphicsTextItem):
            self.pre_editing = False
            self.input_method_text = e.commitString()
        else:
            if self.pre_editing is False:
            if self.pre_editing == False:
                cursor = self.textCursor()
                self.input_method_from = cursor.selectionStart()
            self.pre_editing = True
@@ -98,26 +98,10 @@ class TextBlkItem(QGraphicsTextItem):
                        change_from = self.input_method_from
                        input_method_used = True
            
                        self.input_method_from = -1

                    elif self.change_added > 0:
                        len_text = len(self.toPlainText())
                        cursor = self.textCursor()
                        
                        # if self.change_added >  len_text:
                        #     self.change_added = 1
                        #     change_from = self.textCursor().position() - 1
                        #     input_method_used = True
                        # cursor.setPosition(change_from)
                        # cursor.setPosition(change_from + self.change_added, QTextCursor.MoveMode.KeepAnchor)
                        if self.change_added >  len_text or change_from + self.change_added > len_text:
                            self.change_added = 1
                            change_from = self.textCursor().position() - 1
                            cursor.setPosition(change_from)
                            cursor.setPosition(change_from + self.change_added, QTextCursor.MoveMode.KeepAnchor)
                            added_text = cursor.selectedText()
                            if added_text == '' or added_text == '':
                                    self.change_added = 2
                                    change_from -= 1
                                    
                        cursor.setPosition(change_from)
                        cursor.setPosition(change_from + self.change_added, QTextCursor.MoveMode.KeepAnchor)