mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
Fix reload losing syntax highlighting regression
The regression is introduced by:
de9ffd2ea8
Fix #16027, close #16042
This commit is contained in:
parent
9e1db77f81
commit
e28324b8d0
@ -5034,6 +5034,7 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne, bool forceApplyHili
|
|||||||
// Before switching off, synchronize backup file
|
// Before switching off, synchronize backup file
|
||||||
MainFileManager.backupCurrentBuffer();
|
MainFileManager.backupCurrentBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer * pBuf = MainFileManager.getBufferByID(id);
|
Buffer * pBuf = MainFileManager.getBufferByID(id);
|
||||||
bool reload = pBuf->getNeedReload();
|
bool reload = pBuf->getNeedReload();
|
||||||
if (reload)
|
if (reload)
|
||||||
@ -5041,6 +5042,7 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne, bool forceApplyHili
|
|||||||
MainFileManager.reloadBuffer(id);
|
MainFileManager.reloadBuffer(id);
|
||||||
pBuf->setNeedReload(false);
|
pBuf->setNeedReload(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whichOne == MAIN_VIEW)
|
if (whichOne == MAIN_VIEW)
|
||||||
{
|
{
|
||||||
if (_mainDocTab.activateBuffer(id)) //only activate if possible
|
if (_mainDocTab.activateBuffer(id)) //only activate if possible
|
||||||
|
@ -2279,10 +2279,9 @@ bool ScintillaEditView::setLexerFromLangID(int langID) // Internal lexer only
|
|||||||
|
|
||||||
void ScintillaEditView::activateBuffer(BufferID buffer, bool force)
|
void ScintillaEditView::activateBuffer(BufferID buffer, bool force)
|
||||||
{
|
{
|
||||||
if (buffer == BUFFER_INVALID)
|
if (buffer == BUFFER_INVALID) return;
|
||||||
return;
|
if (!force && buffer == _currentBuffer) return;
|
||||||
if (!force && buffer == _currentBuffer)
|
|
||||||
return;
|
|
||||||
Buffer * newBuf = MainFileManager.getBufferByID(buffer);
|
Buffer * newBuf = MainFileManager.getBufferByID(buffer);
|
||||||
|
|
||||||
// before activating another document, we get the current position
|
// before activating another document, we get the current position
|
||||||
@ -2301,7 +2300,7 @@ void ScintillaEditView::activateBuffer(BufferID buffer, bool force)
|
|||||||
_currentBufferID = buffer; //the magical switch happens here
|
_currentBufferID = buffer; //the magical switch happens here
|
||||||
_currentBuffer = newBuf;
|
_currentBuffer = newBuf;
|
||||||
|
|
||||||
const bool isSameLangType = _prevBuffer != nullptr && ((_prevBuffer == _currentBuffer) || (_prevBuffer->getLangType() == _currentBuffer->getLangType()));
|
const bool isSameLangType = (_prevBuffer != nullptr) && (_prevBuffer->getLangType() == _currentBuffer->getLangType());
|
||||||
const int currentLangInt = static_cast<int>(_currentBuffer->getLangType());
|
const int currentLangInt = static_cast<int>(_currentBuffer->getLangType());
|
||||||
const bool isFirstActiveBuffer = (_currentBuffer->getLastLangType() != currentLangInt);
|
const bool isFirstActiveBuffer = (_currentBuffer->getLastLangType() != currentLangInt);
|
||||||
|
|
||||||
@ -2324,6 +2323,9 @@ void ScintillaEditView::activateBuffer(BufferID buffer, bool force)
|
|||||||
execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
|
execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
|
||||||
execute(SCI_SETDOCPOINTER, 0, _currentBuffer->getDocument());
|
execute(SCI_SETDOCPOINTER, 0, _currentBuffer->getDocument());
|
||||||
execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);
|
execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);
|
||||||
|
|
||||||
|
if (force)
|
||||||
|
defineDocType(_currentBuffer->getLangType());
|
||||||
}
|
}
|
||||||
else // Entering the tab for the 2nd or more times, with the different language type
|
else // Entering the tab for the 2nd or more times, with the different language type
|
||||||
{
|
{
|
||||||
|
@ -453,7 +453,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void activateBuffer(BufferID buffer, bool force = false);
|
void activateBuffer(BufferID buffer, bool force);
|
||||||
|
|
||||||
void getCurrentFoldStates(std::vector<size_t> & lineStateVector);
|
void getCurrentFoldStates(std::vector<size_t> & lineStateVector);
|
||||||
void syncFoldStateWith(const std::vector<size_t> & lineStateVectorNew);
|
void syncFoldStateWith(const std::vector<size_t> & lineStateVectorNew);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user