diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 7436c2c3b..f26b20fab 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2025,6 +2025,9 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapHeight"), &mapPosVal); if (mapPosStr) mapPosition._height = mapPosVal; + mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapKByteInDoc"), &mapPosVal); + if (mapPosStr) + mapPosition._KByteInDoc = mapPosVal; mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapWrapIndentMode"), &mapPosVal); if (mapPosStr) mapPosition._wrapIndentMode = mapPosVal; @@ -2979,6 +2982,7 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) (fileNameNode->ToElement())->SetAttribute(TEXT("mapHigherPos"), viewSessionFiles[i]._mapPos._higherPos); (fileNameNode->ToElement())->SetAttribute(TEXT("mapWidth"), viewSessionFiles[i]._mapPos._width); (fileNameNode->ToElement())->SetAttribute(TEXT("mapHeight"), viewSessionFiles[i]._mapPos._height); + (fileNameNode->ToElement())->SetAttribute(TEXT("mapKByteInDoc"), static_cast(viewSessionFiles[i]._mapPos._KByteInDoc)); (fileNameNode->ToElement())->SetAttribute(TEXT("mapWrapIndentMode"), viewSessionFiles[i]._mapPos._wrapIndentMode); fileNameNode->ToElement()->SetAttribute(TEXT("mapIsWrap"), viewSessionFiles[i]._mapPos._isWrap ? TEXT("yes") : TEXT("no")); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 194b0061e..441e912ad 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -149,8 +149,15 @@ struct MapPosition int32_t _width = -1; int32_t _height = -1; int32_t _wrapIndentMode = -1; + + int64_t _KByteInDoc = _maxPeekLenInKB; + bool _isWrap = false; - bool isValid() { return _firstVisibleDisplayLine != -1; }; + bool isValid() const { return (_firstVisibleDisplayLine != -1); }; + bool canScroll() const { return (_KByteInDoc < _maxPeekLenInKB); }; // _nbCharInDoc < _maxPeekLen : Don't scroll the document for the performance issue + +private: + int64_t _maxPeekLenInKB = 512; // 512 KB }; diff --git a/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp b/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp index a071d8958..687ed700d 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp +++ b/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp @@ -68,6 +68,7 @@ void DocumentPeeker::goTo(POINT p) ::SetWindowPos(_hSelf, HWND_TOP, p.x, p.y + 10, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); } + void DocumentPeeker::syncDisplay(Buffer *buf, ScintillaEditView & scintSource) { if (_pPeekerView) @@ -85,8 +86,10 @@ void DocumentPeeker::syncDisplay(Buffer *buf, ScintillaEditView & scintSource) // Wraping & scrolling // MapPosition mp = buf->getMapPosition(); - if (mp.isValid()) + if (mp.isValid() && mp.canScroll()) + { scrollSnapshotWith(mp); + } Buffer *buf = _pPeekerView->getCurrentBuffer(); _pPeekerView->defineDocType(buf->getLangType()); @@ -140,7 +143,7 @@ void DocumentPeeker::scrollSnapshotWith(const MapPosition & mapPos) // // scroll to the first visible display line - _pPeekerView->execute(SCI_LINESCROLL, 0,mapPos._firstVisibleDisplayLine); + _pPeekerView->execute(SCI_LINESCROLL, 0, mapPos._firstVisibleDisplayLine); } } @@ -180,6 +183,9 @@ void DocumentPeeker::saveCurrentSnapshot(ScintillaEditView & editView) mapPos._higherPos = static_cast(editView.execute(SCI_POSITIONFROMPOINT, 0, 0)); } + // Length of document + mapPos._KByteInDoc = editView.getCurrentDocLen() / 1024; + // set current map position in buffer buffer->setMapPosition(mapPos); }