-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Closed
Closed
Copy link
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Description of the Issue
@donho
When switching between different languages in the main menu Language, the interface would previously freeze for a long time. After my optimization, it is now possible to switch syntax highlighting instantly! It is truly instantaneous, with no delay at all.
The following files need to be modified:
ScintillaEditView.h
void setLanguage(LangType langType); // Quickly set the language
ScintillaEditView.cpp
void ScintillaEditView::setLanguage(LangType langType)
{
const bool isFirstActiveBuffer = (_currentBuffer->getLastLangType() == -1);
Document prev = 0;
LRESULT notifFlag = 0;
if (!isFirstActiveBuffer)
{
saveCurrentPos();
prev = execute(SCI_GETDOCPOINTER);
notifFlag = execute(SCI_GETMODEVENTMASK);
execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
execute(SCI_SETDOCPOINTER, 0, getBlankDocument());
execute(SCI_SETMODEVENTMASK, notifFlag);
}
_currentBuffer->setLangType(langType);
if (!isFirstActiveBuffer)
{
execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
execute(SCI_SETDOCPOINTER, 0, prev);
execute(SCI_SETMODEVENTMASK, notifFlag);
restoreCurrentPosPreStep();
}
}
Notepad_plus.cpp
void Notepad_plus::setLanguage(LangType langType)
{
//...
if (reset)
{
_mainEditView.getCurrentBuffer()->setLangType(langType);
}
else
{
_pEditView->setLanguage(langType); // _pEditView->getCurrentBuffer()->setLangType(langType);
}
//...
}
Describe the solution you'd like.
Quickly set the language.
Debug Information
Notepad++ v8.7.5 (64-bit)
Build time : Dec 21 2024 - 05:13:03
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
Placeholders : OFF
DirectWrite : OFF
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledNew (for current file/tab only)
Dark Mode : OFF
OS Name : Windows 11 Enterprise (64-bit)
OS Version : 24H2
OS Build : 26100.2894
Current ANSI codepage : 1252
Plugins :
mimeTools (3.1)Anything else?
No response
Reactions are currently unavailable