Fixes for the document window state
This commit is contained in:
parent
8422029310
commit
e0612d7e07
|
|
@ -212,12 +212,10 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
||||||
{
|
{
|
||||||
difference |= ProjectDifference.WorkspaceProjectRemoved;
|
difference |= ProjectDifference.WorkspaceProjectRemoved;
|
||||||
}
|
}
|
||||||
else if (
|
else
|
||||||
WorkspaceProject?.Id != workspaceProject?.Id ||
|
|
||||||
WorkspaceProject?.Version != workspaceProject?.Version)
|
|
||||||
{
|
{
|
||||||
// For now this is very naive. We will want to consider changing
|
// We always update the snapshot right now when the project changes. This is how
|
||||||
// our logic here to be more robust.
|
// we deal with changes to the content of C# sources.
|
||||||
difference |= ProjectDifference.WorkspaceProjectChanged;
|
difference |= ProjectDifference.WorkspaceProjectChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -538,8 +538,10 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
||||||
Assert.Equal(ProjectChangeKind.ProjectChanged, ProjectManager.ListenersNotifiedOf);
|
Assert.Equal(ProjectChangeKind.ProjectChanged, ProjectManager.ListenersNotifiedOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We always update the snapshot when someone calls WorkspaceProjectChanged. This is how we deal
|
||||||
|
// with changes to source code, which wouldn't result in a new project.
|
||||||
[ForegroundFact]
|
[ForegroundFact]
|
||||||
public void WorkspaceProjectChanged_WithHostProject_CanNoOp()
|
public void WorkspaceProjectChanged_WithHostProject_NotifiesListeners()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
ProjectManager.HostProjectAdded(HostProject);
|
ProjectManager.HostProjectAdded(HostProject);
|
||||||
|
|
@ -553,6 +555,24 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
||||||
var snapshot = ProjectManager.GetSnapshot(WorkspaceProject);
|
var snapshot = ProjectManager.GetSnapshot(WorkspaceProject);
|
||||||
Assert.True(snapshot.IsInitialized);
|
Assert.True(snapshot.IsInitialized);
|
||||||
|
|
||||||
|
Assert.Equal(ProjectChangeKind.ProjectChanged, ProjectManager.ListenersNotifiedOf);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ForegroundFact]
|
||||||
|
public void WorkspaceProjectChanged_WithHostProject_CanNoOpForSecondProject()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
ProjectManager.HostProjectAdded(HostProject);
|
||||||
|
ProjectManager.WorkspaceProjectAdded(WorkspaceProject);
|
||||||
|
ProjectManager.Reset();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
ProjectManager.WorkspaceProjectChanged(WorkspaceProjectWithDifferentTfm);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var snapshot = ProjectManager.GetSnapshot(WorkspaceProject);
|
||||||
|
Assert.True(snapshot.IsInitialized);
|
||||||
|
|
||||||
Assert.Null(ProjectManager.ListenersNotifiedOf);
|
Assert.Null(ProjectManager.ListenersNotifiedOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,10 @@ namespace Microsoft.VisualStudio.RazorExtension.DocumentInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
var textBuffer = textView.BufferGraph.GetRazorBuffers().FirstOrDefault();
|
var textBuffer = textView.BufferGraph.GetRazorBuffers().FirstOrDefault();
|
||||||
|
if (textBuffer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_editorFactoryService.TryGetDocumentTracker(textBuffer, out _documentTracker))
|
if (!_editorFactoryService.TryGetDocumentTracker(textBuffer, out _documentTracker))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
||||||
{
|
{
|
||||||
changed = project;
|
changed = project;
|
||||||
changed.Snapshot = new ProjectSnapshotViewModel(_projectManager.GetLoadedProject(e.ProjectFilePath));
|
changed.Snapshot = new ProjectSnapshotViewModel(_projectManager.GetLoadedProject(e.ProjectFilePath));
|
||||||
|
DataContext.LoadProjectInfo();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@
|
||||||
Command="{Binding UpdateCommand}" />
|
Command="{Binding UpdateCommand}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<GridSplitter
|
<GridSplitter
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
IsEnabled="False" />
|
IsEnabled="False" />
|
||||||
<Grid
|
<Grid
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
|
|
@ -168,10 +168,14 @@
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
IsEnabled="{Binding CurrentProjectInfo, TargetNullValue=False}">
|
IsEnabled="{Binding CurrentProjectInfo, TargetNullValue=False}">
|
||||||
<Expander.Header>
|
<Expander.Header>
|
||||||
<Grid>
|
<!-- The complicated binding here makes the header stretch horizontally -->
|
||||||
|
<Grid
|
||||||
|
HorizontalAlignment="{Binding HorizontalAlignment, RelativeSource={RelativeSource AncestorType=ContentPresenter}, Mode=OneWayToSource}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition
|
||||||
<ColumnDefinition Width="*" />
|
Width="Auto" />
|
||||||
|
<ColumnDefinition
|
||||||
|
Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Label
|
<Label
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
|
|
@ -181,10 +185,9 @@
|
||||||
Width="Auto"
|
Width="Auto"
|
||||||
Height="20"
|
Height="20"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
Visibility="{Binding CurrentProjectInfo.TagHelperProgressVisibility}"
|
Visibility="{Binding CurrentProjectInfo.TagHelperProgressVisibility, TargetNullValue=Visibility.Hidden}"
|
||||||
IsIndeterminate="True" />
|
IsIndeterminate="True" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</Expander.Header>
|
</Expander.Header>
|
||||||
<ListView
|
<ListView
|
||||||
ItemsSource="{Binding CurrentProjectInfo.TagHelpers}">
|
ItemsSource="{Binding CurrentProjectInfo.TagHelpers}">
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
||||||
_currentProject = value;
|
_currentProject = value;
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
|
|
||||||
LoadProjectInfo(_currentProject.Snapshot.Project);
|
LoadProjectInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,11 +100,11 @@ namespace Microsoft.VisualStudio.RazorExtension.RazorInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public async void LoadProjectInfo()
|
||||||
private async void LoadProjectInfo(ProjectSnapshot snapshot)
|
|
||||||
{
|
{
|
||||||
CurrentProjectInfo = new ProjectInfoViewModel();
|
CurrentProjectInfo = new ProjectInfoViewModel();
|
||||||
|
|
||||||
|
var snapshot = CurrentProject?.Snapshot.Project;
|
||||||
if (snapshot == null)
|
if (snapshot == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue