-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Running Document Table to track open documents
Instead of using the ITextDocumentFactoryService component, we now use IVsRunningDocumentTable to keep track of when files are open and closed in the VS editor. The main reason is that ITextDocumentFactoryService keeps track of all ITextBuffer instances used in VS, including ITextDocument instances loaded for temporary usage, such as the "Find in File" features. This change ensures the number of events related to opening and closing documents is close to zero when using "Find in Files" on large directories or project. This is (hopefully) the last part to fix issue #61
- Loading branch information
Showing
8 changed files
with
374 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
using System.ComponentModel.Composition; | ||
using Microsoft.VisualStudio.Text; | ||
using VsChromium.Package; | ||
|
||
namespace VsChromium.Views { | ||
[Export(typeof(IPackagePostInitializer))] | ||
public class TextDocumentRegistrationManager : IPackagePostInitializer { | ||
private readonly ITextDocumentTable _textDocumentTable; | ||
private readonly IFileRegistrationRequestService _fileRegistrationRequestService; | ||
|
||
[ImportingConstructor] | ||
public TextDocumentRegistrationManager(ITextDocumentTable textDocumentTable, IFileRegistrationRequestService fileRegistrationRequestService) { | ||
_textDocumentTable = textDocumentTable; | ||
_fileRegistrationRequestService = fileRegistrationRequestService; | ||
} | ||
|
||
public int Priority { get { return 0; } } | ||
|
||
public void Run(IVisualStudioPackage package) { | ||
_textDocumentTable.TextDocumentOpened += TextDocumentFactoryServiceOnTextDocumentOpened; | ||
_textDocumentTable.TextDocumentClosed += TextDocumentFactoryServiceOnTextDocumentClosed; | ||
_textDocumentTable.TextDocumentRenamed += TextTextDocumentFactoryServiceOnTextDocumentRenamed; | ||
} | ||
|
||
private void TextDocumentFactoryServiceOnTextDocumentOpened(object sender, TextDocumentEventArgs textDocumentEventArgs) { | ||
_fileRegistrationRequestService.RegisterTextDocument(textDocumentEventArgs.TextDocument); | ||
} | ||
|
||
private void TextDocumentFactoryServiceOnTextDocumentClosed(object sender, TextDocumentEventArgs textDocumentEventArgs) { | ||
_fileRegistrationRequestService.UnregisterTextDocument(textDocumentEventArgs.TextDocument); | ||
} | ||
|
||
private void TextTextDocumentFactoryServiceOnTextDocumentRenamed(object sender, VsDocumentRenameEventArgs e) { | ||
_fileRegistrationRequestService.RegisterFile(e.NewPath.Value); | ||
_fileRegistrationRequestService.UnregisterFile(e.OldPath.Value); | ||
} | ||
} | ||
} |
Oops, something went wrong.