private void OnCaretPositionChanged(object sender, EventArgs eventArgs) { var offset = _textEditor.CaretOffset; var textDocument = _textEditor.Document; var currentTextLocation = textDocument.GetLocation(offset); var columnNumberWithOffset = _elementGenerator.GetColumn(currentTextLocation); var column = columnNumberWithOffset.ColumnNumber + 1; var line = currentTextLocation.Line; if (_previousCaretColumn != column || _previousCaretLine != line) { CaretTextLocationChanged?.Invoke(this, new CaretTextLocationChangedEventArgs(column, line)); _previousCaretColumn = column; _previousCaretLine = line; } }
private void OnCaretPositionChanged(object sender, EventArgs eventArgs) { var location = GetLocation(); if (location is null) { return; } if (_lastLocation is not null && _lastLocation.Offset == location.Offset) { return; } CaretTextLocationChanged?.Invoke(this, new CaretTextLocationChangedEventArgs(location)); _lastLocation = location; }