From b2eb81664b2f8a3c0f4f5465cade0f270aee9996 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Wed, 19 Jun 2024 16:17:26 +1000 Subject: [PATCH] Don't show misc files project in hover info --- .../ProjectSystem/MiscFilesHostProject.cs | 5 +++++ .../ProjectSystem/RazorProjectService.cs | 4 ++-- .../Tooltip/TagHelperTooltipFactoryBase.cs | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesHostProject.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesHostProject.cs index 688545522a..52538e0730 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesHostProject.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesHostProject.cs @@ -17,6 +17,11 @@ internal sealed class MiscFilesHostProject : HostProject { public static MiscFilesHostProject Instance { get; } = Create(); + public static bool IsMiscellaneousProject(IProjectSnapshot project) + { + return project.Key == Instance.Key; + } + public string DirectoryPath { get; } private MiscFilesHostProject( diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs index 916d1a07c1..74ebb39227 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs @@ -271,9 +271,9 @@ internal partial class RazorProjectService : IRazorProjectService, IRazorProject if (_projectManager.IsDocumentOpen(textDocumentPath)) { _logger.LogInformation($"Moving document '{textDocumentPath}' from project '{projectSnapshot.Key}' to misc files because it is open."); - var miscellaneousProject = _projectManager.GetMiscellaneousProject(); - if (projectSnapshot != miscellaneousProject) + if (!MiscFilesHostProject.IsMiscellaneousProject(projectSnapshot)) { + var miscellaneousProject = _projectManager.GetMiscellaneousProject(); MoveDocument(updater, textDocumentPath, fromProject: projectSnapshot, toProject: miscellaneousProject); } } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Tooltip/TagHelperTooltipFactoryBase.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Tooltip/TagHelperTooltipFactoryBase.cs index 7181d82023..8fb3899688 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Tooltip/TagHelperTooltipFactoryBase.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Tooltip/TagHelperTooltipFactoryBase.cs @@ -36,6 +36,11 @@ internal abstract class TagHelperTooltipFactoryBase(IProjectSnapshotManager proj foreach (var project in projectSnapshots) { + if (MiscFilesHostProject.IsMiscellaneousProject(project)) + { + continue; + } + var found = false; var tagHelpers = await project.GetTagHelpersAsync(cancellationToken).ConfigureAwait(false); foreach (var tagHelper in tagHelpers)