diff --git a/Versions/build.txt b/Versions/build.txt
index d00491fd7..0cfbf0888 100644
--- a/Versions/build.txt
+++ b/Versions/build.txt
@@ -1 +1 @@
-1
+2
diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf
index 15ad99ade..f7d8b036f 100644
--- a/res/Notepad3.exe.manifest.conf
+++ b/res/Notepad3.exe.manifest.conf
@@ -3,7 +3,7 @@
Notepad3 RC2
diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp
index 361b78290..31ed5b296 100644
--- a/src/Config/Config.cpp
+++ b/src/Config/Config.cpp
@@ -2078,56 +2078,81 @@ bool MRU_MergeSave(LPMRULIST pmru, bool bAddFiles, bool bRelativePath, bool bUne
// EditSetDocumentBuffer() - Set Document Buffer for Scintilla Edit Component
//
-static bool _CreateNewDocument(const char* lpstrText, DocPosU lenText, int docOptions)
+// @@@ NOTE: CreateDocument and SetDocPointer hangs on WndPaint()/PaintDC()
+// need to debug deeper ....
+
+#if FALSE
+static bool CreateNewDocument(const char* lpstrText, DocPosU lenText, int docOptions)
{
-#define RELEASE_RETURN(ret) { pDocLoad->Release(); return(ret); }
+ #define RELEASE_RETURN(ret) { pDocLoad->Release(); return(ret); }
- ILoader* const pDocLoad = reinterpret_cast(SciCall_CreateLoader(static_cast(lenText) + 1, docOptions));
-
- if (SC_STATUS_OK != pDocLoad->AddData(lpstrText, lenText)) {
- RELEASE_RETURN(false);
+ if (!lpstrText || (lenText == 0)) {
+ SciCall_SetDocPointer(0);
}
- sptr_t const pNewDocumentPtr = (sptr_t)pDocLoad->ConvertToDocument(); // == SciCall_CreateDocument(lenText, docOptions);
- if (!pNewDocumentPtr) {
- RELEASE_RETURN(false);
- }
- SciCall_SetDocPointer(pNewDocumentPtr);
- RELEASE_RETURN(true);
-}
-
-extern "C" bool EditSetDocumentBuffer(const char* lpstrText, DocPosU lenText)
-{
- bool const bLargerThan2GB = (lenText >= ((DocPosU)INT32_MAX));
- bool const bLargeFileLoaded = (lenText >= ((DocPosU)Settings2.FileLoadWarningMB * 1024ULL * 1024ULL));
-
- int const curOptions = SciCall_GetDocumentOptions();
-
- bool result = false;
-
- if (!bLargeFileLoaded && (curOptions & (SC_DOCUMENTOPTION_STYLES_NONE | SC_DOCUMENTOPTION_TEXT_LARGE)))
- {
- int const docOptions = SC_DOCUMENTOPTION_DEFAULT;
- result = _CreateNewDocument(lpstrText, lenText, docOptions);
- }
- else if (!lpstrText || (lenText == 0)) {
- SciCall_ClearAll();
- result = true;
- }
- else if (bLargeFileLoaded)
- {
-#ifdef NP3_LARGE_DOCUMENT_STYLES_NONE
- int const docOptions = bLargeFileLoaded ? (bLargerThan2GB ? SC_DOCUMENTOPTION_TEXT_LARGE : SC_DOCUMENTOPTION_STYLES_NONE) : SC_DOCUMENTOPTION_DEFAULT;
+ else {
+#if 1
+ sptr_t const pNewDocumentPtr = SciCall_CreateDocument(lenText, docOptions);
+ if (pNewDocumentPtr) {
+ SciCall_SetDocPointer(pNewDocumentPtr);
+ SciCall_ReleaseDocument(pNewDocumentPtr);
+ }
+ else {
+ SciCall_SetDocPointer(0);
+ }
+ SciCall_TargetWholeDocument();
+ SciCall_ReplaceTarget(lenText, lpstrText);
#else
- int const docOptions = bLargeFileLoaded ? (bLargerThan2GB ? SC_DOCUMENTOPTION_TEXT_LARGE : SC_DOCUMENTOPTION_DEFAULT) : SC_DOCUMENTOPTION_DEFAULT;
-#endif
+ ILoader* const pDocLoad = reinterpret_cast(SciCall_CreateLoader(static_cast(lenText) + 1, docOptions));
- result = _CreateNewDocument(lpstrText, lenText, docOptions);
+ if (SC_STATUS_OK != pDocLoad->AddData(lpstrText, lenText)) {
+ RELEASE_RETURN(false);
+ }
+ sptr_t const pNewDocumentPtr = (sptr_t)pDocLoad->ConvertToDocument(); // == SciCall_CreateDocument(lenText, docOptions);
+ if (!pNewDocumentPtr) {
+ RELEASE_RETURN(false);
+ }
+ SciCall_SetDocPointer(pNewDocumentPtr);
+ SciCall_ReleaseDocument(pNewDocumentPtr);
+#endif
+ }
+ return true;
+}
+#else
+static bool CreateNewDocument(const char* lpstrText, DocPosU lenText, int docOptions)
+{
+ UNUSED(docOptions);
+ if (!lpstrText || (lenText == 0)) {
+ SciCall_ClearAll();
}
else {
SciCall_TargetWholeDocument();
SciCall_ReplaceTarget(lenText, lpstrText);
- result = true;
}
-
- return result;
+ return true;
+}
+#endif
+
+
+extern "C" bool EditSetDocumentBuffer(const char* lpstrText, DocPosU lenText)
+{
+ bool const bLargerThan2GB = (lenText >= ((DocPosU)INT32_MAX));
+ bool const bLargeFileLoaded = (lenText >= ((DocPosU)Settings2.FileLoadWarningMB << 20));
+ int const docOptions = bLargeFileLoaded ? (bLargerThan2GB ? SC_DOCUMENTOPTION_TEXT_LARGE : SC_DOCUMENTOPTION_STYLES_NONE)
+ : SC_DOCUMENTOPTION_DEFAULT;
+
+ if (SciCall_GetDocumentOptions() != docOptions)
+ {
+ // we have to create a new document with changed options
+ return CreateNewDocument(lpstrText, lenText, docOptions);
+ }
+ else {
+ if (!lpstrText || (lenText == 0)) {
+ SciCall_ClearAll();
+ }
+ else {
+ SciCall_TargetWholeDocument();
+ SciCall_ReplaceTarget(lenText, lpstrText);
+ }
+ }
+ return true;
}
diff --git a/src/Edit.c b/src/Edit.c
index 04a413b94..3ce758833 100644
--- a/src/Edit.c
+++ b/src/Edit.c
@@ -307,54 +307,6 @@ void EditInitWordDelimiter(HWND hwnd)
}
-//=============================================================================
-//
-// EditSetNewText()
-//
-extern bool bFreezeAppTitle;
-
-void XXX_EditSetNewText(HWND hwnd, const char* lpstrText, DocPosU lenText, bool bClearUndoHistory)
-{
- bFreezeAppTitle = true;
-
- // clear markers, flags and positions
- if (bClearUndoHistory) { UndoRedoRecordingStop(); }
- if (FocusedView.HideNonMatchedLines) { EditToggleView(hwnd); }
- _IGNORE_NOTIFY_CHANGE_;
- SciCall_Cancel();
- if (SciCall_GetReadOnly()) { SciCall_SetReadOnly(false); }
- SciCall_MarkerDeleteAll(MARKER_NP3_BOOKMARK);
- EditClearAllOccurrenceMarkers(hwnd);
- SciCall_SetScrollWidth(1);
- SciCall_SetXOffset(0);
- _OBSERVE_NOTIFY_CHANGE_;
-
- FileVars_Apply(&Globals.fvCurFile);
-
- // set new text
- if (lenText > 0) {
- _IGNORE_NOTIFY_CHANGE_;
- SciCall_TargetWholeDocument();
- SciCall_ReplaceTarget(lenText, lpstrText);
- _OBSERVE_NOTIFY_CHANGE_;
- }
- else {
- SciCall_ClearAll();
- }
-
- SciCall_GotoPos(0);
- SciCall_ChooseCaretX();
-
- if (bClearUndoHistory) {
- SciCall_SetSavePoint();
- UndoRedoRecordingStart();
- }
-
- bFreezeAppTitle = false;
-}
-
-
-
//=============================================================================
//
// EditSetNewText()
@@ -363,10 +315,10 @@ extern bool bFreezeAppTitle;
void EditSetNewText(HWND hwnd, const char* lpstrText, DocPosU lenText, bool bClearUndoHistory)
{
- bFreezeAppTitle = true;
-
if (!lpstrText) { lenText = 0; }
+ bFreezeAppTitle = true;
+
// clear markers, flags and positions
if (bClearUndoHistory) { UndoRedoRecordingStop(); }
if (FocusedView.HideNonMatchedLines) { EditToggleView(hwnd); }
@@ -7441,9 +7393,7 @@ void EditDoStyling(DocPos iStartPos, DocPos iEndPos)
{
static bool guard = false; // protect against recursion by notification event SCN_STYLENEEDED
-#ifdef NP3_LARGE_DOCUMENT_STYLES_NONE
- if (Flags.bLargeFileLoaded) { return; }
-#endif
+ //~if (Flags.bLargeFileLoaded) { return; }
if (!guard)
{
diff --git a/src/Styles.c b/src/Styles.c
index 2e4e839b6..6b52c7945 100644
--- a/src/Styles.c
+++ b/src/Styles.c
@@ -968,17 +968,6 @@ static inline bool _IsItemInStyleString(LPCWSTR lpszStyleStrg, LPCWSTR item)
//
void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
{
-#ifdef NP3_LARGE_DOCUMENT_STYLES_NONE
- if (Flags.bLargeFileLoaded)
- {
- s_pLexCurrent = GetLargeFileLexer();
- SciCall_SetIdleStyling(SC_IDLESTYLING_ALL);
- SciCall_StartStyling(0);
- UpdateAllBars(false);
- return;
- }
-#endif
-
// Select standard if NULL is specified
if (!pLexNew) {
pLexNew = Flags.bLargeFileLoaded ? GetLargeFileLexer() : GetDefaultLexer();
@@ -1480,6 +1469,8 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
Style_SetInvisible(hwnd, false); // set fixed invisible style
+ SciCall_StartStyling(0);
+
// apply lexer styles
if (Flags.bLargeFileLoaded)
{
diff --git a/src/TypeDefs.h b/src/TypeDefs.h
index dbc23cadc..6912121f6 100644
--- a/src/TypeDefs.h
+++ b/src/TypeDefs.h
@@ -653,8 +653,6 @@ typedef struct _themeFiles
// --------- common defines --------
-#define NP3_LARGE_DOCUMENT_STYLES_NONE 1
-
#define NOTEPAD3_MODULE_DIR_ENV_VAR L"NOTEPAD3MODULEDIR"
//~#define NP3_VIRTUAL_SPACE_ACCESS_OPTIONS (Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : (SCVS_RECTANGULARSELECTION | SCVS_NOWRAPLINESTART | SCVS_USERACCESSIBLE))
diff --git a/src/VersionEx.h b/src/VersionEx.h
index 31841f295..791ffdac6 100644
--- a/src/VersionEx.h
+++ b/src/VersionEx.h
@@ -9,7 +9,7 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 20
#define VERSION_REV 227
-#define VERSION_BUILD 1
+#define VERSION_BUILD 2
#define SCINTILLA_VER 430
#define ONIGURUMA_REGEX_VER 6.9.4
#define UCHARDET_VER 2018.09.27