Enter: починен перенос строк (был сломан)
- 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 '
This commit is contained in:
@@ -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 = ""
|
||||
|
||||
Reference in New Issue
Block a user