Skip to content

Commit

Permalink
ctrl+z가 되지 않던 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
DCP-arca committed Jun 26, 2024
1 parent 83c96a3 commit 947cefd
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions completer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from PyQt5.QtWidgets import QCompleter, QTextEdit
from PyQt5.QtGui import QTextCursor, QTextCharFormat, QFont, QColor
from PyQt5.QtCore import Qt, QStringListModel
import string

complete_target_stringset = string.ascii_letters + string.digits + "~!#$%^&*_+?.-="


class CustomCompleter(QCompleter):
Expand Down Expand Up @@ -45,11 +48,6 @@ def highlightBrackets(self):
cursor = self.textCursor()
text = self.toPlainText()

# Clear previous formatting
cursor.select(cursor.Document)
clear_format = QTextCharFormat()
cursor.setCharFormat(clear_format)

# Stack to keep track of open brackets
stack = []
bracket_pairs = {'(': ')', '{': '}', '[': ']', '<': '>'}
Expand All @@ -74,13 +72,14 @@ def highlightBrackets(self):
fmt = QTextCharFormat()
fmt.setFontWeight(QFont.Bold)
fmt.setForeground(QColor("red"))
cursor.beginEditBlock()

cursor.beginEditBlock() # Undo block 시작
for pos, matching_pos in bracket_positions.items():
if matching_pos == -1:
cursor.setPosition(pos)
cursor.movePosition(cursor.NextCharacter, cursor.KeepAnchor)
cursor.setCharFormat(fmt)
cursor.endEditBlock()
cursor.endEditBlock() # Undo block 종료
self.blockSignals(False) # 텍스트 변경 후 신호 활성화

def start_complete_mode(self, tag_list):
Expand Down Expand Up @@ -127,7 +126,7 @@ def keyPressEvent(self, event):
if ctrlOrShift and event.text() == '':
return

if event.text():
if event.text() in complete_target_stringset:
# eow = "~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="
eow = "{},<>|@"
hasModifier = (event.modifiers() !=
Expand Down

0 comments on commit 947cefd

Please sign in to comment.