From 88b7e59b2a5cc8f8127b52cc1a8edec2cd6b3400 Mon Sep 17 00:00:00 2001 From: Niels Vaes Date: Mon, 8 Apr 2024 17:40:54 +0200 Subject: [PATCH] * Bug fix for Ctrl -X --- CHANGELOG.md | 4 +++- dcs_code_injector/__init__.py | 2 +- dcs_code_injector/code_editor.py | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 428f9c7..4edd497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ +## 1.4.8 +* Bug fix for Ctrl -X + ## 1.4.7 * Added keyboard shortcut Ctrl -X to delete the current line * Added keyboard shortcut Ctrl -D to duplicate the current line - ## 1.4.6 * Added checkbox in the View menu to turn off the log view in case you're using an external log viewer diff --git a/dcs_code_injector/__init__.py b/dcs_code_injector/__init__.py index 5207f10..ebdb4b5 100644 --- a/dcs_code_injector/__init__.py +++ b/dcs_code_injector/__init__.py @@ -1,6 +1,6 @@ import os -VERSION = "1.4.7" +VERSION = "1.4.8" ICON = os.path.join(os.path.dirname(__file__), "ui", "icons", "icon.png") LOGO = os.path.join(os.path.dirname(__file__), "ui", "icons", "logo.png") UI_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "ui") \ No newline at end of file diff --git a/dcs_code_injector/code_editor.py b/dcs_code_injector/code_editor.py index 5df0c73..830a82e 100644 --- a/dcs_code_injector/code_editor.py +++ b/dcs_code_injector/code_editor.py @@ -363,9 +363,13 @@ def keyPressEvent(self, event: QKeyEvent) -> None: elif event.key() in (Qt.Key_Up, Qt.Key_Down): super().keyPressEvent(event) self.check_cursor_position() - if event.key() == Qt.Key_X and event.modifiers() == Qt.ControlModifier: - self.delete_current_line() - if event.key() == Qt.Key_D and event.modifiers() == Qt.ControlModifier: + elif event.key() == Qt.Key_X and event.modifiers() == Qt.ControlModifier: + cursor: QCursor = self.textCursor() + if cursor.hasSelection(): + super().keyPressEvent(event) + else: + self.delete_current_line() + elif event.key() == Qt.Key_D and event.modifiers() == Qt.ControlModifier: self.duplicate_current_line() elif event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter and not event.modifiers() == Qt.ControlModifier: cursor = self.textCursor()