mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 13:54:54 +02:00
Improve Document Peeker performance issue for large files
This commit is contained in:
parent
8dbd956344
commit
a067de8ce2
@ -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<int>(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"));
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
||||
|
@ -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());
|
||||
@ -180,6 +183,9 @@ void DocumentPeeker::saveCurrentSnapshot(ScintillaEditView & editView)
|
||||
mapPos._higherPos = static_cast<int32_t>(editView.execute(SCI_POSITIONFROMPOINT, 0, 0));
|
||||
}
|
||||
|
||||
// Length of document
|
||||
mapPos._KByteInDoc = editView.getCurrentDocLen() / 1024;
|
||||
|
||||
// set current map position in buffer
|
||||
buffer->setMapPosition(mapPos);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user