/// <summary>
        /// Gets the cached line and ensures it is populated.
        /// </summary>
        /// <param name="lineIndex">The line.</param>
        /// <returns></returns>
        private CachedLine GetCachedLine(int lineIndex)
        {
            if (lineIndex >= lines.Count)
            {
                return(new CachedLine());
            }

            // Pull out the cached line.
            CachedLine cachedLine = lines[lineIndex];

            cachedLine.Cache(EditorViewRenderer, lineIndex);
            return(cachedLine);
        }
        private bool OnIdleUpdate()
        {
            // Make sure we're identified as running.
            isRunning = true;

            // Keep track of when we started. UtcNow requires less CPU overhead
            // so we use that instead.
            DateTime started = DateTime.UtcNow;

            // Loop through the lines in the cache renderer and update each
            // one in turn. We restart at the last point we updated to make sure
            // we can get through all the lines in the short time we have in
            // this loop.
            for (; currentIndex < lines.Count;
                 currentIndex++)
            {
                // Check to see if we exceeded our time yet.
                if ((DateTime.UtcNow - started) > maximumTime)
                {
                    // We have to stop processing now, but we need to keep going.
                    return(true);
                }

                // Get the next line and check to see if it isn't cached. If it
                // isn't, then we need to cache it but also keep track so we
                // go through the lines again.
                CachedLine line = lines[currentIndex];

                if (!line.IsCached)
                {
                    needRestart = true;
                    line.Cache(renderer, currentIndex);
                }
            }

            // If we need to restart, then cycle through it again.
            if (needRestart)
            {
                needRestart  = false;
                currentIndex = 0;
                return(true);
            }

            // If we got this far, we have completely gone through the lines
            // without updating any of them. To avoid the overhead of calling
            // this repeatedly, we return false and will restart later.
            isRunning = false;
            return(false);
        }