[BUG_FIXED] Fix the bug of last session's doc position are not rescrolled on Notepad++ launch time if wrap mode is activated.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@139 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-03-01 19:02:56 +00:00
parent 2b1e41512f
commit c7162f9555
4 changed files with 4 additions and 30 deletions

View File

@ -1953,13 +1953,6 @@ BOOL Notepad_plus::notify(SCNotification *notification)
case SCN_PAINTED: case SCN_PAINTED:
{ {
//Wrapping messes up visible lines, restore after SCN_PAINTED as doc. says
if (_pEditView->needRestoreFromWrap())
{
_pEditView->restoreFromWrap();
}
if (_syncInfo.doSync()) if (_syncInfo.doSync())
doSynScorll(HWND(notification->nmhdr.hwndFrom)); doSynScorll(HWND(notification->nmhdr.hwndFrom));

View File

@ -93,7 +93,6 @@ struct HeaderLineState {
struct Position struct Position
{ {
int _firstVisibleLine; int _firstVisibleLine;
int _wrapOffset;
int _startPos; int _startPos;
int _endPos; int _endPos;
int _xOffset; int _xOffset;

View File

@ -872,13 +872,13 @@ void ScintillaEditView::saveCurrentPos()
//Save data so, that the current topline becomes visible again after restoring. //Save data so, that the current topline becomes visible again after restoring.
int displayedLine = static_cast<int>(execute(SCI_GETFIRSTVISIBLELINE)); int displayedLine = static_cast<int>(execute(SCI_GETFIRSTVISIBLELINE));
int docLine = execute(SCI_DOCLINEFROMVISIBLE, displayedLine); //linenumber of the line displayed in the top int docLine = 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 //int offset = displayedLine - execute(SCI_VISIBLEFROMDOCLINE, docLine); //use this to calc offset of wrap. If no wrap this should be zero
Buffer & buf = _buffers[_currentIndex]; Buffer & buf = _buffers[_currentIndex];
// the correct visible line number // the correct visible line number
buf._pos._firstVisibleLine = docLine;//docLine - nbInvisibleLine; buf._pos._firstVisibleLine = docLine;//docLine - nbInvisibleLine;
buf._pos._wrapOffset = offset;
buf._pos._startPos = static_cast<int>(execute(SCI_GETSELECTIONSTART)); buf._pos._startPos = static_cast<int>(execute(SCI_GETSELECTIONSTART));
buf._pos._endPos = static_cast<int>(execute(SCI_GETSELECTIONEND)); buf._pos._endPos = static_cast<int>(execute(SCI_GETSELECTIONEND));
buf._pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET)); buf._pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET));
@ -892,12 +892,6 @@ void ScintillaEditView::restoreCurrentPos()
Buffer & buf = _buffers[_currentIndex]; Buffer & buf = _buffers[_currentIndex];
if (!_wrapRestoreNeeded)
{
int lineToShow = execute(SCI_VISIBLEFROMDOCLINE, buf._pos._firstVisibleLine);
scroll(0, lineToShow);
}
if (buf._pos._selMode == SC_SEL_RECTANGLE) if (buf._pos._selMode == SC_SEL_RECTANGLE)
{ {
execute(SCI_SETSELECTIONMODE, buf._pos._selMode); execute(SCI_SETSELECTIONMODE, buf._pos._selMode);
@ -905,18 +899,10 @@ void ScintillaEditView::restoreCurrentPos()
execute(SCI_SETSELECTIONSTART, buf._pos._startPos); execute(SCI_SETSELECTIONSTART, buf._pos._startPos);
execute(SCI_SETSELECTIONEND, buf._pos._endPos); execute(SCI_SETSELECTIONEND, buf._pos._endPos);
execute(SCI_SETXOFFSET, buf._pos._xOffset); execute(SCI_SETXOFFSET, buf._pos._xOffset);
}
void ScintillaEditView::restoreFromWrap()
{
Buffer & buf = _buffers[_currentIndex];
// these 2 lines should be at the end so it works in wrap mode
int lineToShow = execute(SCI_VISIBLEFROMDOCLINE, buf._pos._firstVisibleLine); int lineToShow = execute(SCI_VISIBLEFROMDOCLINE, buf._pos._firstVisibleLine);
scroll(0, lineToShow);
//Scroll to the line that corresponds to the stored docline and then some more for the wrapping offset.
//Should work with folding too.
scroll(0, lineToShow + buf._pos._wrapOffset);
_wrapRestoreNeeded = false;
} }

View File

@ -243,10 +243,6 @@ public:
void saveCurrentPos(); void saveCurrentPos();
void restoreCurrentPos(); void restoreCurrentPos();
bool needRestoreFromWrap() {
return _wrapRestoreNeeded;
}
void restoreFromWrap();
Buffer & getBufferAt(size_t index) { Buffer & getBufferAt(size_t index) {