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); } } }
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); } } }