@@ -90,6 +90,7 @@ CScintillaWnd::CScintillaWnd(HINSTANCE hInst)
9090 , m_bCursorShown(true )
9191 , m_bScratch(false )
9292 , m_eraseBkgnd(true )
93+ , m_hugeLevelReached(false )
9394 , m_cursorTimeout(-1 )
9495 , m_bInFolderMargin(false )
9596 , m_hasConsolas(false )
@@ -1023,7 +1024,7 @@ void CScintillaWnd::RestoreCurrentPos(const CPosData& pos)
10231024 UpdateLineNumberWidth ();
10241025}
10251026
1026- void CScintillaWnd::SetupLexerForLang (const std::string& lang) const
1027+ void CScintillaWnd::SetupLexerForLang (const std::string& lang)
10271028{
10281029 const auto & lexerData = CLexStyles::Instance ().GetLexerDataForLang (lang);
10291030 const auto & keywords = CLexStyles::Instance ().GetKeywordsForLang (lang);
@@ -1103,6 +1104,14 @@ void CScintillaWnd::SetupLexerForLang(const std::string& lang) const
11031104 {
11041105 m_scintilla.SetProperty (propName.c_str (), propValue.c_str ());
11051106 }
1107+ auto length = m_scintilla.Length ();
1108+ m_hugeLevelReached = false ;
1109+ if (length > 500 * 1024 * 1024 )
1110+ {
1111+ // turn off folding
1112+ m_scintilla.SetProperty (" fold" , " 0" );
1113+ m_hugeLevelReached = true ;
1114+ }
11061115 for (const auto & [styleId, styleData] : lexerData.styles )
11071116 {
11081117 m_scintilla.StyleSetFore (styleId, theme.GetThemeColor (styleData.foregroundColor , true ));
@@ -1476,16 +1485,17 @@ void CScintillaWnd::MarkSelectedWord(bool clear, bool edit)
14761485 m_scintilla.SetIndicatorCurrent (INDIC_SELECTION_MARK);
14771486 m_scintilla.IndicatorClearRange (startStylePos, len);
14781487
1479- auto sSelText = m_scintilla.GetSelText ();
1480- auto selTextLen = sSelText .size ();
1481- if ((selTextLen == 0 ) || (clear))
1488+ auto selSpan = m_scintilla.SelectionSpan ();
1489+ if (clear || selSpan.Length () == 0 || selSpan.Length () + 10000 )
14821490 {
14831491 lastSelText.clear ();
14841492 m_docScroll.Clear (DOCSCROLLTYPE_SELTEXT);
14851493 m_selTextMarkerCount = 0 ;
14861494 SendMessage (*this , WM_NCPAINT, static_cast <WPARAM>(1 ), 0 );
14871495 return ;
14881496 }
1497+ auto sSelText = m_scintilla.GetSelText ();
1498+ auto selTextLen = sSelText .size ();
14891499 auto origSelStart = m_scintilla.SelectionStart ();
14901500 auto origSelEnd = m_scintilla.SelectionEnd ();
14911501 auto selStartLine = m_scintilla.LineFromPosition (origSelStart);
@@ -1692,7 +1702,8 @@ void CScintillaWnd::MatchBraces(BraceMatch what)
16921702 SetTimer (*this , TIM_BRACEHIGHLIGHTTEXT, 1000 , nullptr );
16931703 }
16941704
1695- if ((what == BraceMatch::Highlight) && (m_scintilla.IndentationGuides () != Scintilla::IndentView::None))
1705+ if ((braceAtCaret >= 0 ) && (braceOpposite >= 0 ) && (what == BraceMatch::Highlight) &&
1706+ (m_scintilla.IndentationGuides () != Scintilla::IndentView::None))
16961707 {
16971708 auto columnAtCaret = m_scintilla.Column (braceAtCaret);
16981709 auto columnOpposite = m_scintilla.Column (braceOpposite);
@@ -2548,6 +2559,16 @@ void CScintillaWnd::ReflectEvents(SCNotification* pScn)
25482559 case SCN_SAVEPOINTREACHED:
25492560 EnableChangeHistory ();
25502561 break ;
2562+ case SCN_MODIFIED:
2563+ if (pScn->modificationType & SC_MOD_INSERTTEXT)
2564+ {
2565+ if (!m_hugeLevelReached && m_scintilla.Length () > 500 * 1024 * 1024 )
2566+ {
2567+ // turn off folding
2568+ m_scintilla.SetProperty (" fold" , " 0" );
2569+ m_hugeLevelReached = true ;
2570+ }
2571+ }
25512572 default :
25522573 break ;
25532574 }
0 commit comments