Fix scintilla restoring wrapped buffer issue
When we are restoring a wrapped buffer, we send SCI_VISIBLEFROMDOCLINE message to convert a file line number to a visual line number, scintalla seems to ignore the "wrap" option of this buffer. Workaroud: execute SCI_ENSUREVISIBLE after set position and before executing SCI_VISIBLEFROMDOCLINE. It seems that this issue has been encountered in ScitillaComponent/FindReplaceDlg.cpp in Searching::displaySectionCentered Fix #4571, close #4624
This commit is contained in:
parent
050ba58a80
commit
40192bda0c
|
@ -2040,7 +2040,7 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
|
|||
(childNode->ToElement())->Attribute(TEXT("endPos"), &position._endPos);
|
||||
(childNode->ToElement())->Attribute(TEXT("selMode"), &position._selMode);
|
||||
(childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth);
|
||||
|
||||
(childNode->ToElement())->Attribute(TEXT("offset"), &position._offset);
|
||||
MapPosition mapPosition;
|
||||
int32_t mapPosVal;
|
||||
const TCHAR *mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDisplayLine"), &mapPosVal);
|
||||
|
|
|
@ -134,6 +134,7 @@ struct Position
|
|||
int _xOffset = 0;
|
||||
int _selMode = 0;
|
||||
int _scrollWidth = 1;
|
||||
int _offset = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1755,7 +1755,7 @@ void ScintillaEditView::saveCurrentPos()
|
|||
//Save data so, that the current topline becomes visible again after restoring.
|
||||
int32_t displayedLine = static_cast<int32_t>(execute(SCI_GETFIRSTVISIBLELINE));
|
||||
int32_t docLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, displayedLine)); //linenumber of the line displayed in the top
|
||||
//int offset = displayedLine - execute(SCI_VISIBLEFROMDOCLINE, docLine); //use this to calc offset of wrap. If no wrap this should be zero
|
||||
int32_t offset = displayedLine - static_cast<int32_t>(execute(SCI_VISIBLEFROMDOCLINE, docLine)); //use this to calc offset of wrap. If no wrap this should be zero
|
||||
|
||||
Buffer * buf = MainFileManager->getBufferByID(_currentBufferID);
|
||||
|
||||
|
@ -1767,6 +1767,7 @@ void ScintillaEditView::saveCurrentPos()
|
|||
pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET));
|
||||
pos._selMode = static_cast<int32_t>(execute(SCI_GETSELECTIONMODE));
|
||||
pos._scrollWidth = static_cast<int32_t>(execute(SCI_GETSCROLLWIDTH));
|
||||
pos._offset = offset;
|
||||
|
||||
buf->setPosition(pos, this);
|
||||
}
|
||||
|
@ -1788,8 +1789,11 @@ void ScintillaEditView::restoreCurrentPos()
|
|||
execute(SCI_SETXOFFSET, pos._xOffset);
|
||||
}
|
||||
execute(SCI_CHOOSECARETX); // choose current x position
|
||||
execute(SCI_ENSUREVISIBLE); //Make sure the caret is visible (this will also fix wrapping problems)
|
||||
|
||||
int lineToShow = static_cast<int32_t>(execute(SCI_VISIBLEFROMDOCLINE, pos._firstVisibleLine));
|
||||
lineToShow += pos._offset;
|
||||
|
||||
scroll(0, lineToShow);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue