public void LoadRevision(GitRevision revision)
        {
            _revision = revision;
            _revisionFileTreeController.ResetCache();

            try
            {
                tvGitTree.SuspendLayout();
                // Save state only when there is selected node
                if (tvGitTree.SelectedNode != null)
                {
                    var node = tvGitTree.SelectedNode;
                    FileText.SaveCurrentScrollPos();
                    _lastSelectedNodes.Clear();
                    while (node != null)
                    {
                        _lastSelectedNodes.Push(node.Text);
                        node = node.Parent;
                    }
                }

                // Refresh tree
                tvGitTree.Nodes.Clear();
                //restore selected file and scroll position when new selection is done
                if (_revision != null)
                {
                    _revisionFileTreeController.LoadChildren(_revision, tvGitTree.Nodes, tvGitTree.ImageList.Images);
                    //GitTree.Sort();
                    TreeNode lastMatchedNode = null;
                    // Load state
                    var      currenNodes = tvGitTree.Nodes;
                    TreeNode matchedNode = null;
                    while (_lastSelectedNodes.Count > 0 && currenNodes != null)
                    {
                        var next = _lastSelectedNodes.Pop();
                        foreach (TreeNode node in currenNodes)
                        {
                            if (node.Text != next && next.Length != 40)
                            {
                                continue;
                            }

                            node.Expand();
                            matchedNode = node;
                            break;
                        }
                        if (matchedNode == null)
                        {
                            currenNodes = null;
                        }
                        else
                        {
                            lastMatchedNode = matchedNode;
                            currenNodes     = matchedNode.Nodes;
                        }
                    }
                    //if there is no exact match, don't restore scroll position
                    if (lastMatchedNode != matchedNode)
                    {
                        FileText.ResetCurrentScrollPos();
                    }
                    tvGitTree.SelectedNode = lastMatchedNode;
                }
                if (tvGitTree.SelectedNode == null)
                {
                    FileText.ViewText("", "");
                }
            }
            finally
            {
                tvGitTree.ResumeLayout();
            }
        }
        public void LoadRevision([CanBeNull] GitRevision revision)
        {
            _revision = revision;
            _revisionFileTreeController.ResetCache();

            try
            {
                tvGitTree.SuspendLayout();

                // Save state only when there is selected node
                if (tvGitTree.SelectedNode != null)
                {
                    var node = tvGitTree.SelectedNode;
                    _lastSelectedNodes.Clear();
                    while (node != null)
                    {
                        _lastSelectedNodes.Push(node.Text);
                        node = node.Parent;
                    }
                }

                // Refresh tree
                tvGitTree.Nodes.Clear();

                // restore selected file and scroll position when new selection is done
                if (_revision != null && !_revision.IsArtificial && tvGitTree.ImageList != null)
                {
                    _revisionFileTreeController.LoadChildren(_revision, tvGitTree.Nodes, tvGitTree.ImageList.Images);
                    ////GitTree.Sort();
                    TreeNode lastMatchedNode = null;

                    // Load state
                    var      currentNodes = tvGitTree.Nodes;
                    TreeNode matchedNode  = null;
                    while (_lastSelectedNodes.Count > 0 && currentNodes != null)
                    {
                        var next = _lastSelectedNodes.Pop();
                        foreach (TreeNode node in currentNodes)
                        {
                            if (node.Text != next && next.Length != 40)
                            {
                                continue;
                            }

                            node.Expand();
                            matchedNode = node;
                            break;
                        }

                        if (matchedNode == null)
                        {
                            currentNodes = null;
                        }
                        else
                        {
                            lastMatchedNode = matchedNode;
                            currentNodes    = matchedNode.Nodes;
                        }
                    }

                    tvGitTree.SelectedNode = lastMatchedNode;
                }

                if (tvGitTree.SelectedNode == null)
                {
                    ThreadHelper.JoinableTaskFactory.Run(() => FileText.ViewTextAsync("", ""));
                }
            }
            finally
            {
                tvGitTree.ResumeLayout();
            }
        }
        public void LoadRevision([CanBeNull] GitRevision revision)
        {
            _revision = revision;
            _revisionFileTreeController.ResetCache();

            // needed to make sure that the locks "list" is up to date
            _revisionFileTreeController.GitLfsLocks = Module.GetLocks().Select(x => "\\" + x.Path.Replace('/', '\\')).ToArray();

            try
            {
                tvGitTree.SuspendLayout();

                // Save state only when there is selected node
                if (tvGitTree.SelectedNode != null)
                {
                    var node = tvGitTree.SelectedNode;
                    _lastSelectedNodes.Clear();
                    while (node != null)
                    {
                        _lastSelectedNodes.Push(node.Text);
                        node = node.Parent;
                    }
                }

                // Refresh tree
                tvGitTree.Nodes.Clear();

                // restore selected file and scroll position when new selection is done
                if (_revision != null && !_revision.IsArtificial && tvGitTree.ImageList != null)
                {
                    _revisionFileTreeController.LoadChildren(_revision, tvGitTree.Nodes, tvGitTree.ImageList.Images);
                    ////GitTree.Sort();
                    TreeNode lastMatchedNode = null;

                    // Load state
                    var      currentNodes = tvGitTree.Nodes;
                    TreeNode matchedNode  = null;
                    while (_lastSelectedNodes.Count > 0 && currentNodes != null)
                    {
                        var next = _lastSelectedNodes.Pop();
                        foreach (TreeNode node in currentNodes)
                        {
                            if (node.Text != next && next.Length != 40)
                            {
                                continue;
                            }

                            node.Expand();
                            matchedNode = node;
                            break;
                        }

                        if (matchedNode == null)
                        {
                            currentNodes = null;
                        }
                        else
                        {
                            lastMatchedNode = matchedNode;
                            currentNodes    = matchedNode.Nodes;
                        }
                    }

                    tvGitTree.SelectedNode = lastMatchedNode;
                }

                if (tvGitTree.SelectedNode == null)
                {
                    FileText.Clear();
                }
            }
            finally
            {
                tvGitTree.ResumeLayout();
            }
        }