private async System.Threading.Tasks.Task OnCaretPositionChangedSubjectHandlerAsync(CaretPositionChangedSubject e)
        {
            try {
                if (e == null || e.EventArgs == null)
                {
                    return;
                }

                var wpfTextView = e.WpfTextView;
                if (wpfTextView == null || !SessionService.IsReady || !SessionService.IsWebViewVisible || !SessionService.IsCodemarksForFileVisible)
                {
                    return;
                }
                if (!wpfTextView.Properties.TryGetProperty(PropertyNames.TextViewFilePath, out string filePath))
                {
                    return;
                }
                if (filePath.IsNullOrWhiteSpace())
                {
                    return;
                }
                if (!Uri.TryCreate(filePath, UriKind.RelativeOrAbsolute, out Uri result))
                {
                    return;
                }

                Debug.WriteLine($"{nameof(OnCaretPositionChangedSubjectHandlerAsync)} new={e.EventArgs.NewPosition} old={e.EventArgs.OldPosition}");
                var cursorLine = wpfTextView.TextSnapshot.GetLineFromPosition(e.EventArgs.NewPosition.BufferPosition.Position);
                _ = CodeStreamService.ChangeCaretAsync(result, wpfTextView.ToVisibleRangesSafe(), cursorLine.LineNumber, wpfTextView.TextSnapshot.LineCount);
            }
            catch (Exception ex) {
                Log.Warning(ex, nameof(OnCaretPositionChangedSubjectHandlerAsync));
            }
        }
        private void ChangeActiveEditor(IWpfTextView wpfTextView)
        {
            try {
                if (wpfTextView == null || !SessionService.IsWebViewVisible)
                {
                    return;
                }
                if (!wpfTextView.Properties.TryGetProperty(PropertyNames.TextViewFilePath, out string filePath))
                {
                    return;
                }
                if (filePath.IsNullOrWhiteSpace())
                {
                    return;
                }

                var activeTextEditor = EditorService.GetActiveTextEditor(TextDocumentFactoryService, wpfTextView);
                if (activeTextEditor != null && activeTextEditor.Uri != null)
                {
                    if (Uri.TryCreate(filePath, UriKind.RelativeOrAbsolute, out Uri result))
                    {
                        if (activeTextEditor.Uri.EqualsIgnoreCase(result))
                        {
                            _ = CodeStreamService.ChangeActiveEditorAsync(new Uri(filePath), activeTextEditor);
                            SetZoomLevel(wpfTextView.ZoomLevel);
                        }
                    }
                }
            }
            catch (Exception ex) {
                Log.Warning(ex, nameof(ChangeActiveEditor));
            }
        }
 private void ResetActiveEditor()
 {
     try {
         _ = CodeStreamService.ResetActiveEditorAsync();
         _focusedWpfTextView = null;
         SessionService.LastActiveFileUrl = null;
     }
     catch (Exception ex) {
         Log.Warning(ex, nameof(ResetActiveEditor));
     }
 }
        private async System.Threading.Tasks.Task OnTextSelectionChangedSubjectHandlerAsync(TextSelectionChangedSubject subject)
        {
            try {
                Debug.WriteLine($"{nameof(OnTextSelectionChangedSubjectHandlerAsync)} {subject.TextSelection.ToPositionString()}");
                var wpfTextView       = subject.WpfTextView;
                var activeEditorState = EditorService?.GetEditorState(wpfTextView);

                _ = CodeStreamService.EditorSelectionChangedNotificationAsync(
                    wpfTextView.Properties.GetProperty <string>(PropertyNames.TextViewFilePath).ToUri(),
                    activeEditorState,
                    wpfTextView.ToVisibleRangesSafe(),
                    wpfTextView?.TextSnapshot?.LineCount,
                    CodemarkType.Comment, CancellationToken.None);
            }
            catch (Exception ex) {
                Log.Warning(ex, nameof(OnTextSelectionChangedSubjectHandlerAsync));
            }
        }