- fix: Don't auto scroll to the caret after undo/redo.
This commit is contained in:
parent
b3247dd2e8
commit
5a5f047f1e
1
NEWS.md
1
NEWS.md
|
@ -2,6 +2,7 @@ Red Panda C++ Version 3.2
|
||||||
|
|
||||||
- Change: The way to calcuate astyle path.
|
- Change: The way to calcuate astyle path.
|
||||||
- fix: Scroll bar arrow size not correct in the dark themes.
|
- fix: Scroll bar arrow size not correct in the dark themes.
|
||||||
|
- fix: Don't auto scroll to the caret after undo/redo.
|
||||||
|
|
||||||
Red Panda C++ Version 3.1
|
Red Panda C++ Version 3.1
|
||||||
|
|
||||||
|
|
|
@ -2960,33 +2960,10 @@ void QSynEdit::ensureCaretVisible()
|
||||||
|
|
||||||
void QSynEdit::ensureCaretVisibleEx(bool ForceToMiddle)
|
void QSynEdit::ensureCaretVisibleEx(bool ForceToMiddle)
|
||||||
{
|
{
|
||||||
if (mDocument->maxLineWidth()<0) {
|
|
||||||
if (ForceToMiddle)
|
|
||||||
mStateFlags.setFlag(StateFlag::EnsureCaretVisibleForceMiddle, true);
|
|
||||||
else
|
|
||||||
mStateFlags.setFlag(StateFlag::EnsureCaretVisible, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
auto action = finally([this]{
|
auto action = finally([this]{
|
||||||
decPaintLock();
|
decPaintLock();
|
||||||
});
|
});
|
||||||
// Make sure X is visible
|
|
||||||
int visibleX = displayX();
|
|
||||||
if (visibleX < leftPos()) {
|
|
||||||
if (viewWidth() / 3 >visibleX)
|
|
||||||
setLeftPos(0);
|
|
||||||
else if (viewWidth() > tabWidth() + mCharWidth)
|
|
||||||
setLeftPos(std::max(0,visibleX - tabWidth()));
|
|
||||||
else
|
|
||||||
setLeftPos(visibleX);
|
|
||||||
} else if (visibleX > viewWidth() + leftPos() - mCharWidth && viewWidth()>0)
|
|
||||||
if (viewWidth() >= 3*mCharWidth )
|
|
||||||
setLeftPos(visibleX - viewWidth() + 3*mCharWidth);
|
|
||||||
else
|
|
||||||
setLeftPos(visibleX - viewWidth() + mCharWidth);
|
|
||||||
else
|
|
||||||
setLeftPos(leftPos());
|
|
||||||
// Make sure Y is visible
|
// Make sure Y is visible
|
||||||
int vCaretRow = displayY();
|
int vCaretRow = displayY();
|
||||||
if (ForceToMiddle) {
|
if (ForceToMiddle) {
|
||||||
|
@ -3003,6 +2980,29 @@ void QSynEdit::ensureCaretVisibleEx(bool ForceToMiddle)
|
||||||
} else
|
} else
|
||||||
setTopPos(mTopPos);
|
setTopPos(mTopPos);
|
||||||
}
|
}
|
||||||
|
// Make sure X is visible
|
||||||
|
if (mDocument->maxLineWidth()<0) {
|
||||||
|
if (ForceToMiddle)
|
||||||
|
mStateFlags.setFlag(StateFlag::EnsureCaretVisibleForceMiddle, true);
|
||||||
|
else
|
||||||
|
mStateFlags.setFlag(StateFlag::EnsureCaretVisible, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int visibleX = displayX();
|
||||||
|
if (visibleX < leftPos()) {
|
||||||
|
if (viewWidth() / 3 >visibleX)
|
||||||
|
setLeftPos(0);
|
||||||
|
else if (viewWidth() > tabWidth() + mCharWidth)
|
||||||
|
setLeftPos(std::max(0,visibleX - tabWidth()));
|
||||||
|
else
|
||||||
|
setLeftPos(visibleX);
|
||||||
|
} else if (visibleX > viewWidth() + leftPos() - mCharWidth && viewWidth()>0)
|
||||||
|
if (viewWidth() >= 3*mCharWidth )
|
||||||
|
setLeftPos(visibleX - viewWidth() + 3*mCharWidth);
|
||||||
|
else
|
||||||
|
setLeftPos(visibleX - viewWidth() + mCharWidth);
|
||||||
|
else
|
||||||
|
setLeftPos(leftPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::scrollWindow(int dx, int dy)
|
void QSynEdit::scrollWindow(int dx, int dy)
|
||||||
|
@ -4112,6 +4112,7 @@ void QSynEdit::doUndo()
|
||||||
} while (keepGoing);
|
} while (keepGoing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ensureCaretVisible();
|
||||||
updateModifiedStatus();
|
updateModifiedStatus();
|
||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
|
@ -4315,6 +4316,7 @@ void QSynEdit::doRedo()
|
||||||
PUndoItem item = mRedoList->popItem();
|
PUndoItem item = mRedoList->popItem();
|
||||||
mUndoList->restoreChange(item);
|
mUndoList->restoreChange(item);
|
||||||
}
|
}
|
||||||
|
ensureCaretVisible();
|
||||||
updateModifiedStatus();
|
updateModifiedStatus();
|
||||||
onChanged();
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue