コード例 #1
0
        private void UnregisterAndDeleteBookmark(List <Bookmark> bookmarks, Bookmark bookmark, ITextBuffer buffer, bool notifyIfLastBookmark = true)
        {
            var tagger = Helpers.GetTaggerFor(buffer);

            tagger?.RemoveTagSpan(bookmark.TrackingSpan);
            bookmarks.Remove(bookmark);

            if (bookmarks.Count == 0 && notifyIfLastBookmark)
            {
                SolutionExplorerFilter.OnFileLostItsLastBookmark(buffer.Properties["fileName"] as string);
            }
        }
コード例 #2
0
        private void RegisterAndCreateBookmark(List <Bookmark> bookmarks, ITextBuffer buffer, string fileName, int lineNumber)
        {
            var trackingSpan = CreateTagSpan(buffer, lineNumber);

            if (trackingSpan != null)
            {
                bookmarks.Add(new Bookmark(trackingSpan));
                if (bookmarks.Count == 1)
                {
                    SolutionExplorerFilter.OnFileGotItsFirstBookmark(fileName);
                }
            }
        }
コード例 #3
0
        public void RecreateBookmarksFromSerializedInfo(SerializableBookmarksInfo info)
        {
            foreach (var item in info.FilesWithBookmarks)
            {
                var fileName = Path.Combine(SolutionPath, item.FileName); //Filename could be absolute, then this is a NOP, that's ok
                if (!File.Exists(fileName))
                {
                    continue;
                }

                var lineNumbers = item.Lines;

                if (activeViewsByFilename.ContainsKey(fileName))
                {
                    var view      = activeViewsByFilename[fileName];
                    var buffer    = view.TextBuffer;
                    var bookmarks = bookmarksByView[view];
                    foreach (var lineNumber in lineNumbers)
                    {
                        var bookmarkExists = bookmarks.Any(b => b.GetRow(buffer) == lineNumber);
                        if (!bookmarkExists)
                        {
                            RegisterAndCreateBookmark(bookmarks, buffer, fileName, lineNumber);
                        }
                    }
                }
                else if (bookmarksPendingCreation.ContainsKey(fileName))
                {
                    bookmarksPendingCreation[fileName] = bookmarksPendingCreation[fileName].Union(lineNumbers).ToArray();
                }
                else
                {
                    bookmarksPendingCreation.Add(fileName, lineNumbers);
                    SolutionExplorerFilter.OnFileGotItsFirstBookmark(fileName);
                }
            }
        }