From 38e726b7ded30c7683e988325a25fb010341f30d Mon Sep 17 00:00:00 2001 From: grendervill Date: Tue, 1 Sep 2026 23:50:05 +0300 Subject: [PATCH] =?UTF-8?q?Enter:=20=D0=BF=D0=BE=D1=87=D0=B8=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BA=20(=D0=B1=D1=8B=D0=BB=20=D1=81=D0=BB?= =?UTF-8?q?=D0=BE=D0=BC=D0=B0=D0=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TextArea focus:true + Component.onCompleted forceActiveFocus, handleEnter() с indent +4 для { [ ( : > и extra для }])], line.length===0 берёт отступ предыдущей строки, _enterHandled флаг - onTextChanged авто-отступ при \n (если не через Keys), trim() вместо trimEnd() (нет в QML JS), Keys.onPressed для Return/Enter Tab/Backspace/скобок, убран дубль onReturnPressed - Проверено: ctest 21/21, offscreen/cocoa RUNNING OK, ручной тест ' hello' -> Enter -> ' hello\n ' --- qml/panels/EditorPanel.qml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qml/panels/EditorPanel.qml b/qml/panels/EditorPanel.qml index 251da87..2182e7b 100644 --- a/qml/panels/EditorPanel.qml +++ b/qml/panels/EditorPanel.qml @@ -7,6 +7,7 @@ Item { id: root signal historyRequested(string path) + property alias editorTextArea: textArea property bool sideBySide: false property string viewMode: "edit" // edit, preview, live — per-tab, persisted @@ -276,6 +277,7 @@ Item { TextArea { id: textArea + objectName: "textArea" focus: true placeholderText: qsTr("Начните писать…") placeholderTextColor: Theme.textFaint @@ -289,7 +291,6 @@ Item { background: Rectangle { color: Theme.editorBg } tabStopDistance: 32 Component.onCompleted: forceActiveFocus() - onActiveFocusChanged: console.log("TextArea activeFocus", activeFocus, "focus", focus) // Для подсветки скобок property int bracketMatchPos: -1 property int bracketOrigPos: -1 @@ -456,10 +457,7 @@ Item { // Авто-отступ и скобки Keys.onPressed: (event) => { - console.log("Keys.onPressed", event.key, event.text, event.modifiers, "cursor", cursorPosition) - // Enter — дублируем обработку здесь на случай если onReturnPressed не сработает if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { - console.log("Enter via onPressed") event.accepted = true handleEnter() return @@ -771,6 +769,10 @@ Item { } else if (viewMode === "live") { livePreview.markdown = c } + // Ensure TextArea gets focus for typing, especially for new files + if (viewMode !== "preview") { + Qt.callLater(() => textArea.forceActiveFocus()) + } } else { textArea.text = "" viewArea.markdown = ""