/// <summary> /// Check and see if we should start an external edit operation /// </summary> private void CheckForExternalEditStart(CheckKind kind) { Contract.Assert(_buffer.ModeKind != ModeKind.ExternalEdit); var externalEditSpans = GetExternalEditSpans(kind); // If at some point all of the external edit spans dissapear then we // don't need to track them anymore. Very important to clear the cache // here as the user could fire up an external edit at the exact same location // and we want that to register as an external edit if (externalEditSpans.Count == 0) { _ignoredExternalEditSpans.Clear(); return; } // If we should ignore all of the spans then we've not entered an external // edit if (externalEditSpans.All(ShouldIgnore)) { return; } // Clear out the ignored markers. Everything is fair game again when we restart // the external edit _ignoredExternalEditSpans.Clear(); // Not in an external edit and there are edit markers we need to consider. Time to enter // external edit mode _buffer.SwitchMode(ModeKind.ExternalEdit, ModeArgument.None); }
internal List <SnapshotSpan> GetExternalEditSpans(CheckKind kind) { var list = new List <SnapshotSpan>(); GetExternalEditSpans(list, kind); return(list); }
private bool IsExternalEditStart(CheckKind kind) { Contract.Assert(_vimBuffer.ModeKind != ModeKind.ExternalEdit); if (GetAnyExternalEditActive()) { return(true); } var externalEditSpans = GetExternalEditSpans(kind); if (externalEditSpans.Count == 0) { // If at some point all of the external edit spans dissapear then we // don't need to track them anymore. Very important to clear the cache // here as the user could fire up an external edit at the exact same location // and we want that to register as an external edit _ignoredExternalEditSpans.Clear(); return(false); } // If we should ignore all of the spans then we've not entered an external // edit if (externalEditSpans.All(ShouldIgnore)) { return(false); } return(true); }
/// <summary> /// Perform the specified check against the ITextBuffer /// </summary> internal void PerformCheck(CheckKind kind) { if (!_vimApplicationSettings.EnableExternalEditMonitoring || _vimBuffer.ModeKind == ModeKind.Disabled) { return; } if (kind == CheckKind.None) { return; } // If we're in the middle of a layout then there is no sense in checking now as the values // will all be invalidated when the layout ends. Queue one up for later if (_vimBuffer.TextView.InLayout) { QueueCheck(kind); return; } if (_vimBuffer.ModeKind == ModeKind.ExternalEdit) { CheckForExternalEditEnd(); } else { CheckForExternalEditStart(kind); } }
/// <summary> /// Queue up a check for the specified type here. If there is already check queued /// this wont' have any effect other than to ensure the specified check is included /// in the existing queue /// </summary> private void QueueCheck(CheckKind kind) { if (_queuedCheckKind.HasValue) { _queuedCheckKind |= kind; return; } Action doCheck = () => { var saved = _queuedCheckKind ?? kind; _queuedCheckKind = null; // The ITextView can close in between the time of dispatch and the actual // execution of the call. // // In addition to being the right thing to do by bailing out early, there are parts // of the SHIM layer which can't handle being called after the ITextView is // called. EnumMarkers for example will throw a NullReferenceException. if (_textView.IsClosed) { return; } PerformCheck(saved); }; _protectedOperations.BeginInvoke(doCheck, DispatcherPriority.Loaded); }
/// <summary> /// Check and see if we should start an external edit operation /// </summary> private void CheckForExternalEditStart(CheckKind kind) { Contract.Assert(_vimBuffer.ModeKind != ModeKind.ExternalEdit); if (IsExternalEditStart(kind)) { // Clear out the ignored markers. Everything is fair game again when we restart // the external edit _ignoredExternalEditSpans.Clear(); // Not in an external edit and there are edit markers we need to consider. Time to enter // external edit mode _controlExternalEdit = true; _vimBuffer.SwitchMode(ModeKind.ExternalEdit, ModeArgument.None); } }
private void GetExternalEditSpans(List<SnapshotSpan> list, CheckKind kind) { var collection = _buffer.TextView.GetLikelyVisibleSnapshotSpans(); foreach (var span in collection) { if (0 != (kind & CheckKind.Markers)) { GetExternalEditSpansFromMarkers(span, list); } if (0 != (kind & CheckKind.Tags)) { GetExternalEditSpansFromTags(span, list); } } }
public StringCheck(string expected, CheckKind check = CheckKind.Equals) { Expected = expected; Kind = check; Custom = null; }
/// <summary> /// Queue up a check for the specified type here. If there is already check queued /// this wont' have any effect other than to ensure the specified check is included /// in the existing queue /// </summary> private void QueueCheck(CheckKind kind) { if (_queuedCheckKind.HasValue) { _queuedCheckKind |= kind; return; } Action doCheck = () => { var saved = _queuedCheckKind ?? kind; _queuedCheckKind = null; PerformCheck(saved); }; Dispatcher.CurrentDispatcher.BeginInvoke(doCheck, DispatcherPriority.Loaded); }
private bool IsExternalEditStart(CheckKind kind) { Contract.Assert(_vimBuffer.ModeKind != ModeKind.ExternalEdit); if (GetAnyExternalEditActive()) { return true; } var externalEditSpans = GetExternalEditSpans(kind); if (externalEditSpans.Count == 0) { // If at some point all of the external edit spans dissapear then we // don't need to track them anymore. Very important to clear the cache // here as the user could fire up an external edit at the exact same location // and we want that to register as an external edit _ignoredExternalEditSpans.Clear(); return false; } // If we should ignore all of the spans then we've not entered an external // edit if (externalEditSpans.All(ShouldIgnore)) { return false; } return true; }
internal List<SnapshotSpan> GetExternalEditSpans(CheckKind kind) { var list = new List<SnapshotSpan>(); GetExternalEditSpans(list, kind); return list; }
private void startRadioButton_CheckedChanged(object sender, EventArgs e) { if (startRadioButton.Checked) checkKind = CheckKind.Star; }
private void crossRadioButton_CheckedChanged(object sender, EventArgs e) { if (crossRadioButton.Checked) checkKind = CheckKind.Cross; }
/// <summary> /// Perform the specified check against the ITextBuffer /// </summary> internal void PerformCheck(CheckKind kind) { if (kind == CheckKind.None) { return; } // If we're in the middle of a layout then there is no sense in checking now as the values // will all be invalidated when the layout ends. Queue one up for later if (_buffer.TextView.InLayout) { QueueCheck(kind); return; } if (_buffer.ModeKind == ModeKind.ExternalEdit) { CheckForExternalEditEnd(); } else { CheckForExternalEditStart(kind); } }