Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

question about m_NeedsBatchColour variable in CC


When the parsing for a project is done, we can make a simple syntax highlight on the editors.
The variable m_NeedsBatchColour is used to record that after the ParserEnd event, all the opened editors should be highlighted. Do we really need that, because I see

--- Code: ---void CodeCompletion::OnEditorActivatedTimer(cb_unused wxTimerEvent& event)

--- End code ---

So, generally, I think we don't need to refresh the syntax highlight after the ParserEnd event. Here is the patch:

--- Code: --- src/plugins/codecompletion/codecompletion.cpp | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/plugins/codecompletion/codecompletion.cpp b/src/plugins/codecompletion/codecompletion.cpp
index 9666a3f..9d8ab6e 100644
--- a/src/plugins/codecompletion/codecompletion.cpp
+++ b/src/plugins/codecompletion/codecompletion.cpp
@@ -2568,17 +2568,11 @@ void CodeCompletion::OnParserEnd(wxCommandEvent& event)
         m_ToolbarNeedReparse = true;
         TRACE(_T("CodeCompletion::OnParserEnd: Starting m_TimerToolbar."));
         m_TimerToolbar.Start(TOOLBAR_REFRESH_DELAY, wxTIMER_ONE_SHOT);
-    }
-    if (m_NeedsBatchColour)
-    {
-        for (int edIdx = edMan->GetEditorsCount() - 1; edIdx >= 0; --edIdx)
+        if (m_NeedsBatchColour)
-            editor = edMan->GetBuiltinEditor(edIdx);
-            if (editor)
-                UpdateEditorSyntax(editor);
+            UpdateEditorSyntax(editor);
+            m_NeedsBatchColour = false;
-        m_NeedsBatchColour = false;

--- End code ---

What do you think?


--- Quote from: ollydbg on August 19, 2015, 06:20:34 am ---What do you think?

--- End quote ---
It might cause a slight delay which can be visible. Do you experience such after the patch?


--- Quote from: MortenMacFly on August 19, 2015, 08:04:27 am ---
--- Quote from: ollydbg on August 19, 2015, 06:20:34 am ---What do you think?

--- End quote ---
It might cause a slight delay which can be visible. Do you experience such after the patch?

--- End quote ---

Yes, I can see the visible delay. For example, a project have four files: a.cpp, b.cpp, c.cpp, d.cpp, when project loaded, a.cpp and b.cpp will be opened automatically, suppose b.cpp is the active editor.

The old code is that when finish parsing the project, the opened editors(a.cpp and b.cpp) will be colourised. When I switch to a.cpp, the a.cpp will colourised again, but you don't notice the visible delay, because a.cpp is already colourised. While, if you double click on the c.cpp in the project manager tree, c.cpp will opened and activated, and you notice the visible delay on c.cpp.

After my patch, after parsing the project, only b.cpp(the active editor) will be colourised, when you switch to a.cpp or open c.cpp, you will notice the visual delay.

BTW: I notice that if I double click on the c.cpp in the project file tree, I will receive many editor active events, see below:

--- Code: ---20:40:00,156  =>  cbEVT_EDITOR_DEACTIVATED
20:40:00,156  =>  cbEVT_EDITOR_SWITCHED
20:40:00,156  =>  cbEVT_EDITOR_ACTIVATED
Mozilla universal detection engine detected 'Pure *ASCII*'.
Final encoding detected: Windows Chinese Simplified (CP 936) (ID: 28)
Conversion succeeded using wxCSConv (buffer size = 143129, converted size = 143130.
20:40:00,218  =>  cbEVT_EDITOR_OPEN
20:40:00,250  =>  cbEVT_EDITOR_SWITCHED
20:40:00,250  =>  cbEVT_EDITOR_ACTIVATED
20:40:00,250  =>  cbEVT_EDITOR_SWITCHED
20:40:00,250  =>  cbEVT_EDITOR_ACTIVATED
20:40:00,265  =>  cbEVT_EDITOR_UPDATE_UI
NativeParser::GetAllPathsByFilename(): Traversing 'F:\cb_sf_git\trunk\src\plugins\codecompletion\parser' for: parserthread.*
NativeParser::GetAllPathsByFilename(): Found 2 files:
- F:\cb_sf_git\trunk\src\plugins\codecompletion\parser\parserthread.cpp
- F:\cb_sf_git\trunk\src\plugins\codecompletion\parser\parserthread.h
ClassBrowser::OnThreadEvent(): Updating class browser...
20:40:00,687  =>  cbEVT_EDITOR_UPDATE_UI
ClassBrowser::OnThreadEvent(): Class browser updated.

--- End code ---
This is reported by Jens' event monitor plugin. when a new file "parserthread.cpp" is opened by double click on the project manager tree. Not sure why, but I think that's one reason why we need an "editor active timer delay", thus we can only handle the last activated editor event.


[0] Message Index

Go to full version