Exemplo n.º 1
0
        async Task Initialize()
        {
            needsInitialize = false;

            var bufferInfo = sessionManager.GetTextBufferInfo(buffer);

            if (bufferInfo != null)
            {
                session      = bufferInfo.Session;
                relativePath = bufferInfo.RelativePath;
                file         = await session.GetFile(relativePath);

                fileSubscription = file.LinesChanged.Subscribe(LinesChanged);
                side             = bufferInfo.Side ?? DiffSide.Right;
                NotifyTagsChanged();
            }
            else
            {
                await InitializeLiveFile();

                sessionManagerSubscription = sessionManager
                                             .WhenAnyValue(x => x.CurrentSession)
                                             .Skip(1)
                                             .Subscribe(_ => ForgetWithLogging(InitializeLiveFile()));
            }
        }
Exemplo n.º 2
0
        async Task Initialize()
        {
            needsInitialize = false;

            var bufferInfo = sessionManager.GetTextBufferInfo(buffer);

            if (bufferInfo != null)
            {
                session      = bufferInfo.Session;
                relativePath = bufferInfo.RelativePath;
                file         = await session.GetFile(relativePath);

                leftHandSide = bufferInfo.IsLeftComparisonBuffer;
                NotifyTagsChanged();
            }
            else
            {
                await InitializeLiveFile();

                sessionManagerSubscription = sessionManager
                                             .WhenAnyValue(x => x.CurrentSession)
                                             .Skip(1)
                                             .Subscribe(_ => ForgetWithLogging(InitializeLiveFile()));
            }
        }
Exemplo n.º 3
0
        public async Task Initialize()
        {
            var buffer = peekSession.TextView.TextBuffer;
            var info   = sessionManager.GetTextBufferInfo(buffer);

            if (info != null)
            {
                relativePath = info.RelativePath;
                side         = info.Side ?? DiffSide.Right;
                file         = await info.Session.GetFile(relativePath);

                session = info.Session;
                await UpdateThread();
            }
            else
            {
                relativePath = sessionManager.GetRelativePath(buffer);
                file         = await sessionManager.GetLiveFile(relativePath, peekSession.TextView, buffer);
                await SessionChanged(sessionManager.CurrentSession);

                sessionSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession)
                                      .Skip(1)
                                      .Subscribe(x => SessionChanged(x).Forget());
            }

            fileSubscription?.Dispose();
            fileSubscription = file.LinesChanged.Subscribe(LinesChanged);
        }
        public async Task Initialize()
        {
            var buffer = peekSession.TextView.TextBuffer;
            var info   = sessionManager.GetTextBufferInfo(buffer);

            if (info != null)
            {
                relativePath = info.RelativePath;
                leftBuffer   = info.IsLeftComparisonBuffer;
                file         = await info.Session.GetFile(relativePath);

                session = info.Session;
                await UpdateThread();
            }
            else
            {
                relativePath = sessionManager.GetRelativePath(buffer);
                file         = await sessionManager.GetLiveFile(relativePath, peekSession.TextView, buffer);
                await SessionChanged(sessionManager.CurrentSession);

                sessionSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession)
                                      .Skip(1)
                                      .Subscribe(x => SessionChanged(x).Forget());
            }

            fileSubscription = file.WhenAnyValue(x => x.InlineCommentThreads).Subscribe(_ => UpdateThread().Forget());
        }
        bool IsMarginVisible(ITextBuffer buffer)
        {
            if (sessionManager.GetTextBufferInfo(buffer) != null)
            {
                return(true);
            }

            InlineCommentTagger inlineCommentTagger;

            if (buffer.Properties.TryGetProperty(typeof(InlineCommentTagger), out inlineCommentTagger))
            {
                if (inlineCommentTagger.ShowMargin)
                {
                    return(true);
                }
            }

            var projection = buffer as IProjectionBuffer;

            if (projection != null)
            {
                foreach (var source in projection.SourceBuffers)
                {
                    if (IsMarginVisible(source))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        async Task RefreshCurrentSession()
        {
            var sessionFile = await FindSessionFile();

            hasChanges = sessionFile?.Diff != null && sessionFile.Diff.Count > 0;

            await Task.Yield(); // HACK: Give diff view a chance to initialize.

            var info = sessionManager.GetTextBufferInfo(textView.TextBuffer);

            hasInfo = info != null;

            RefreshMarginVisibility();
        }
        bool IsMarginVisible(ITextBuffer buffer)
        {
            if (sessionManager.GetTextBufferInfo(buffer) != null)
            {
                return(true);
            }

            InlineCommentTagger inlineCommentTagger;

            if (buffer.Properties.TryGetProperty(typeof(InlineCommentTagger), out inlineCommentTagger))
            {
                if (inlineCommentTagger.ShowMargin)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 8
0
        void Initialize()
        {
            document = buffer.Properties.GetProperty <ITextDocument>(typeof(ITextDocument));

            if (document == null)
            {
                return;
            }

            var bufferInfo = sessionManager.GetTextBufferInfo(buffer);
            IPullRequestSession session = null;

            if (bufferInfo != null)
            {
                fullPath     = bufferInfo.FilePath;
                leftHandSide = bufferInfo.IsLeftComparisonBuffer;

                if (!bufferInfo.Session.IsCheckedOut)
                {
                    session = bufferInfo.Session;
                }
            }
            else
            {
                fullPath = document.FilePath;
            }

            if (session == null)
            {
                managerSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession).Subscribe(SessionChanged);
            }
            else
            {
                SessionChanged(session);
            }

            initialized = true;
        }
        void Initialize()
        {
            document = TryGetDocument(buffer);

            if (document == null)
            {
                return;
            }

            var bufferInfo = sessionManager.GetTextBufferInfo(buffer);
            IPullRequestSession session = null;

            if (bufferInfo != null)
            {
                fullPath     = bufferInfo.FilePath;
                leftHandSide = bufferInfo.IsLeftComparisonBuffer;

                if (!bufferInfo.Session.IsCheckedOut)
                {
                    session = bufferInfo.Session;
                }
            }
            else
            {
                fullPath = document.FilePath;
            }

            if (session == null)
            {
                managerSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession).Subscribe(x => ForgetWithLogging(SessionChanged(x)));
            }
            else
            {
                ForgetWithLogging(SessionChanged(session));
            }

            initialized = true;
        }
        public async Task Initialize()
        {
            var buffer = peekSession.TextView.TextBuffer;
            var info   = sessionManager.GetTextBufferInfo(buffer);

            if (info != null)
            {
                fullPath   = info.FilePath;
                leftBuffer = info.IsLeftComparisonBuffer;
                await SessionChanged(info.Session);
            }
            else
            {
                var document = buffer.Properties.GetProperty <ITextDocument>(typeof(ITextDocument));
                fullPath = document.FilePath;

                await SessionChanged(sessionManager.CurrentSession);

                sessionManager.WhenAnyValue(x => x.CurrentSession)
                .Skip(1)
                .Subscribe(x => SessionChanged(x).Forget());
            }
        }