mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-13 05:44:11 +02:00
Added a wait-for-classify on initial showing to reduce color flashing
This commit is contained in:
parent
287922693e
commit
ba2c4faa59
2 changed files with 21 additions and 4 deletions
|
@ -15,8 +15,9 @@ namespace IDE
|
||||||
public Action mOnThreadDone ~ delete _;
|
public Action mOnThreadDone ~ delete _;
|
||||||
[ThreadStatic]
|
[ThreadStatic]
|
||||||
public static bool mBpSetThreadName;
|
public static bool mBpSetThreadName;
|
||||||
|
WaitEvent mWaitEvent = new WaitEvent() ~ delete _;
|
||||||
|
|
||||||
public void DoBackground(ThreadStart threadStart, Action onThreadDone = null)
|
public void DoBackground(ThreadStart threadStart, Action onThreadDone = null, int maxWait = 0)
|
||||||
{
|
{
|
||||||
Debug.Assert(Thread.CurrentThread == IDEApp.sApp.mMainThread);
|
Debug.Assert(Thread.CurrentThread == IDEApp.sApp.mMainThread);
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ namespace IDE
|
||||||
|
|
||||||
mOnThreadDone = onThreadDone;
|
mOnThreadDone = onThreadDone;
|
||||||
mThreadRunning = true;
|
mThreadRunning = true;
|
||||||
|
mWaitEvent.Reset();
|
||||||
|
|
||||||
ThreadPool.QueueUserWorkItem(new () =>
|
ThreadPool.QueueUserWorkItem(new () =>
|
||||||
{
|
{
|
||||||
|
@ -51,7 +53,15 @@ namespace IDE
|
||||||
mThread = null;
|
mThread = null;
|
||||||
mThreadRunning = false;
|
mThreadRunning = false;
|
||||||
BeefPerf.Event("DoBackground:threadEnd", "");
|
BeefPerf.Event("DoBackground:threadEnd", "");
|
||||||
|
|
||||||
|
mWaitEvent.Set();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (maxWait != 0)
|
||||||
|
{
|
||||||
|
if (mWaitEvent.WaitFor(maxWait))
|
||||||
|
CheckThreadDone();
|
||||||
|
}
|
||||||
//mBfSystem.PerfZoneEnd();
|
//mBfSystem.PerfZoneEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,10 +190,10 @@ namespace IDE
|
||||||
return (mThreadWorker.mThreadRunning || mThreadWorkerHi.mThreadRunning);
|
return (mThreadWorker.mThreadRunning || mThreadWorkerHi.mThreadRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoBackground(ThreadStart threadStart, Action onThreadDone = null)
|
public void DoBackground(ThreadStart threadStart, Action onThreadDone = null, int maxWait = 0)
|
||||||
{
|
{
|
||||||
CancelBackground();
|
CancelBackground();
|
||||||
mThreadWorker.DoBackground(threadStart, onThreadDone);
|
mThreadWorker.DoBackground(threadStart, onThreadDone, maxWait);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoBackgroundHi(ThreadStart threadStart, Action onThreadDone = null)
|
public void DoBackgroundHi(ThreadStart threadStart, Action onThreadDone = null)
|
||||||
|
|
|
@ -1148,11 +1148,16 @@ namespace IDE.ui
|
||||||
compiler.DoBackgroundHi(new () => { DoClassify(.Autocomplete, resolveParams, true); }, new => ClassifyThreadDone);
|
compiler.DoBackgroundHi(new () => { DoClassify(.Autocomplete, resolveParams, true); }, new => ClassifyThreadDone);
|
||||||
//BackgroundResolve(new () => { DoClassify(.Autocomplete, resolveParams); });
|
//BackgroundResolve(new () => { DoClassify(.Autocomplete, resolveParams); });
|
||||||
else if (useResolveType == .ClassifyFullRefresh)
|
else if (useResolveType == .ClassifyFullRefresh)
|
||||||
|
{
|
||||||
|
// To avoid "flashing" on proper colorization vs FastClassify, we wait a bit for the proper classifying to finish
|
||||||
|
// on initial show
|
||||||
|
int maxWait = (mUpdateCnt <= 1) ? 50 : 0;
|
||||||
compiler.DoBackground(new () => { DoClassify(.ClassifyFullRefresh, resolveParams, false); },
|
compiler.DoBackground(new () => { DoClassify(.ClassifyFullRefresh, resolveParams, false); },
|
||||||
new () =>
|
new () =>
|
||||||
{
|
{
|
||||||
ClassifyThreadDone();
|
ClassifyThreadDone();
|
||||||
});
|
}, maxWait);
|
||||||
|
}
|
||||||
else if (useResolveType == .GetCurrentLocation)
|
else if (useResolveType == .GetCurrentLocation)
|
||||||
compiler.DoBackgroundHi(new () => { DoClassify(.GetCurrentLocation, resolveParams, true); }, new => ClassifyThreadDone);
|
compiler.DoBackgroundHi(new () => { DoClassify(.GetCurrentLocation, resolveParams, true); }, new => ClassifyThreadDone);
|
||||||
else if (useResolveType == .GetSymbolInfo)
|
else if (useResolveType == .GetSymbolInfo)
|
||||||
|
@ -5425,6 +5430,8 @@ namespace IDE.ui
|
||||||
|
|
||||||
// Wait longer for Clang since it'll delay autocompletions whereas Beef can be interrupted
|
// Wait longer for Clang since it'll delay autocompletions whereas Beef can be interrupted
|
||||||
int32 classifyDelayTicks = (mIsBeefSource || (mUpdateCnt < 40)) ? 2 : 40;
|
int32 classifyDelayTicks = (mIsBeefSource || (mUpdateCnt < 40)) ? 2 : 40;
|
||||||
|
if (mUpdateCnt <= 1)
|
||||||
|
classifyDelayTicks = 0;
|
||||||
|
|
||||||
if (mWantsBackgroundAutocomplete)
|
if (mWantsBackgroundAutocomplete)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue