Example #1
0
        /// <summary>
        /// Gets a snapshot that can be used to perform searches. A snapshot is only useful if the buffer content or dimensions have not changed.
        /// </summary>
        public SearchSnapshot GetSnapshot()
        {
            if (cache == null)
            {
                var result = CalculateSnapshot();
                cache = result;
            }

            return(cache);
        }
Example #2
0
        SearchSnapshot CalculateSnapshot(Line [] lines)
        {
            var result = new SearchSnapshot(lines);

            return(result);
        }
Example #3
0
 /// <summary>
 /// Invalidates the current search snapshot due to content or size changes.
 /// The cache should be invalidated when either the content of the buffer or the buffer dimensions change
 /// because the snapshot has direct mappings to buffer line and locations.
 /// </summary>
 public void Invalidate()
 {
     // TODO: ideally this would be private and handled completely by the search service and consumers don't have to call this
     Invalidated?.Invoke(this, cache?.LastSearch);
     cache = null;
 }