mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+chg: try to preserve caret position after recoding
This commit is contained in:
parent
a9999a8646
commit
eabdaef50e
@ -524,9 +524,11 @@ bool EditConvertText(HWND hwnd, cpi_enc_t encSource, cpi_enc_t encDest)
|
||||
if (pchText) {
|
||||
WideCharToMultiByteEx(Encoding_SciCP, 0, pwchText, -1, pchText, cbText, NULL, NULL);
|
||||
FreeMem(pwchText);
|
||||
DocPos const curPos = SciCall_GetCurrentPos();
|
||||
EditSetNewText(hwnd, pchText, (cbText - 1), true, false);
|
||||
Encoding_Current(encDest);
|
||||
FreeMem(pchText);
|
||||
Sci_GotoPosTop(curPos);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
@ -6919,7 +6919,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (iPos != iAnchor) {
|
||||
UndoTransActionBegin();
|
||||
SciCall_SetSel(iPos, iPos);
|
||||
SciCall_GotoPos(iPos);
|
||||
EndUndoTransAction();
|
||||
} else {
|
||||
if (iPos == iStartPos) {
|
||||
@ -6943,7 +6943,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (iPos != iAnchor) {
|
||||
UndoTransActionBegin();
|
||||
SciCall_SetSel(iPos, iPos);
|
||||
SciCall_GotoPos(iPos);
|
||||
EndUndoTransAction();
|
||||
} else {
|
||||
if (iStartPos != iEndPos) {
|
||||
@ -8478,7 +8478,7 @@ static void _HandleAutoCloseTags()
|
||||
}
|
||||
if ((cchIns > 3) && !isNonClosingTag) {
|
||||
EditReplaceSelection(replaceBuf, false);
|
||||
SciCall_SetSel(iCurPos, iCurPos);
|
||||
SciCall_GotoPos(iCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -805,6 +805,8 @@ DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool);
|
||||
//~#define Sci_GetDocEndPosition() SciCall_GetTextLength()
|
||||
#define Sci_GetDocEndPosition() SciCall_PositionAfter(SciCall_GetTextLength() - 1)
|
||||
|
||||
#define Sci_GotoPosTop(position) { SciCall_GotoPos(Sci_GetDocEndPosition()); SciCall_GotoPos(curPos); }
|
||||
|
||||
#define Sci_ClampAlpha(alpha) clampi((alpha), SC_ALPHA_TRANSPARENT, SC_ALPHA_OPAQUE) //~SC_ALPHA_NOALPHA
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user