Ejemplo n.º 1
0
        private async System.Threading.Tasks.Task OnVisibleRangesSubjectHandlerAsync(Uri uri, IWpfTextView wpfTextView)
        {
            try {
                if (wpfTextView.InLayout || wpfTextView.IsClosed || SessionService.WebViewDidInitialize != true)
                {
                    return;
                }

                _ = CodeStreamService.BrowserService?.NotifyAsync(
                    new HostDidChangeEditorVisibleRangesNotificationType {
                    Params = new HostDidChangeEditorVisibleRangesNotification(
                        uri,
                        EditorService.GetEditorState(wpfTextView)?.ToEditorSelectionsSafe(),
                        wpfTextView.ToVisibleRangesSafe(),
                        wpfTextView.TextSnapshot?.LineCount
                        )
                });
            }
            catch (InvalidOperationException ex) {
                Log.Warning(ex, nameof(OnVisibleRangesSubjectHandlerAsync));
            }
            catch (Exception ex) {
                Log.Error(ex, nameof(OnVisibleRangesSubjectHandlerAsync));
            }
            await System.Threading.Tasks.Task.CompletedTask;
        }
Ejemplo n.º 2
0
        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));
            }
        }