/// <summary> /// Clear the document and token list. This will also clear the undo/redo history. /// </summary> public void Clear() { lock (_tokensLock) { _tokens.Clear(); _visibleTokens.Clear(); TextDocument.Selection.Expand(TextRangeUnit.Story); TextDocument.Selection.Delete(TextRangeUnit.Story, 0); TextDocument.ClearUndoRedoHistory(); } }
/// <summary> /// Clear unused tokens and undo/redo history. /// </summary> public void ClearUndoRedoSuggestionHistory() { TextDocument.ClearUndoRedoHistory(); lock (_tokensLock) { if (_tokens.Count == 0) { return; } var keysToDelete = _tokens.Where(pair => !pair.Value.Active).Select(pair => pair.Key).ToArray(); foreach (var key in keysToDelete) { _tokens.Remove(key); } } }