Only compute undoable/redoable states using currently focused item
This commit is contained in:
parent
dcfa5fe889
commit
8a9340dae5
2 changed files with 26 additions and 21 deletions
|
|
@ -61,29 +61,31 @@ Item {
|
|||
}
|
||||
|
||||
onTextChanged: {
|
||||
if (fixedCursorPosition != -1) {
|
||||
cursorPosition = fixedCursorPosition
|
||||
fixedCursorPosition = -1
|
||||
}
|
||||
if (index >= 0) {
|
||||
if (index > 0 && text[0] != sentinelChar) {
|
||||
forceCommit()
|
||||
document.focusedIndex = index - 1
|
||||
document.focusedItem.fixCursorPosition()
|
||||
Lisp.call("models:join-node", index, text)
|
||||
} else {
|
||||
var split = text.indexOf("\n")
|
||||
if (split != -1) {
|
||||
if (visible) {
|
||||
if (fixedCursorPosition != -1) {
|
||||
cursorPosition = fixedCursorPosition
|
||||
fixedCursorPosition = -1
|
||||
}
|
||||
if (index >= 0) {
|
||||
if (index > 0 && text[0] != sentinelChar) {
|
||||
forceCommit()
|
||||
Lisp.call("models:split-node", index, text.substring(index > 0 ? 1 : 0, split), text.substring(split + 1))
|
||||
document.nextCursorPosition = 1
|
||||
document.focusedIndex = index + 1
|
||||
document.focusedIndex = index - 1
|
||||
document.focusedItem.fixCursorPosition()
|
||||
Lisp.call("models:join-node", index, text)
|
||||
} else {
|
||||
lastText = getText()
|
||||
textModified = lastText != content
|
||||
undo.enabled = textModified || Lisp.call("models:can-undo-p")
|
||||
redo.enabled = !textModified && Lisp.call("models:can-redo-p")
|
||||
save.enabled = textModified || Lisp.call("models:can-save-p")
|
||||
var split = text.indexOf("\n")
|
||||
if (split != -1) {
|
||||
forceCommit()
|
||||
Lisp.call("models:split-node", index, text.substring(index > 0 ? 1 : 0, split), text.substring(split + 1))
|
||||
document.nextCursorPosition = 1
|
||||
document.focusedIndex = index + 1
|
||||
} else {
|
||||
lastText = getText()
|
||||
textModified = lastText != content
|
||||
undo.enabled = textModified || Lisp.call("models:can-undo-p")
|
||||
redo.enabled = !textModified && Lisp.call("models:can-redo-p")
|
||||
save.enabled = textModified || Lisp.call("models:can-save-p")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ Page {
|
|||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
icon.source: "image://theme/icon-m-rotate-left"
|
||||
enabled: false
|
||||
|
||||
onClicked: {
|
||||
if (document.focusedItem != null) {
|
||||
|
|
@ -81,6 +82,7 @@ Page {
|
|||
anchors.left: undo.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
icon.source: "image://theme/icon-m-rotate-right"
|
||||
enabled: false
|
||||
|
||||
onClicked: {
|
||||
document.focusedIndex = -1
|
||||
|
|
@ -95,6 +97,7 @@ Page {
|
|||
anchors.right: settings.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
icon.source: "image://theme/icon-m-sd-card"
|
||||
enabled: false
|
||||
|
||||
onClicked: {
|
||||
if (document.focusedItem != null) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue