Skip to content

Commit 9cc3496

Browse files
authored
🐛 Minor fixes related to projects (#87)
1 parent 5c941ef commit 9cc3496

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/SharpIDE.Application/Features/Analysis/RoslynAnalysis.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,12 @@ public async Task<ImmutableArray<SharpIdeRazorClassifiedSpan>> GetRazorDocumentS
492492
using var _ = SharpIdeOtel.Source.StartActivity($"{nameof(RoslynAnalysis)}.{nameof(GetRazorDocumentSyntaxHighlighting)}");
493493
await _solutionLoadedTcs.Task;
494494
var timer = Stopwatch.StartNew();
495-
var project = GetProjectForSharpIdeFile(fileModel);
496495
if (fileModel.IsRazorFile is false)
497496
{
498497
return [];
499498
//throw new InvalidOperationException("File is not a .razor file");
500499
}
500+
var project = GetProjectForSharpIdeFile(fileModel);
501501
var razorDocument = project.AdditionalDocuments.Single(s => s.FilePath == fileModel.Path);
502502

503503
var razorProjectSnapshot = _snapshotManager!.GetSnapshot(project);
@@ -598,13 +598,13 @@ public async Task<ImmutableArray<SharpIdeClassifiedSpan>> GetDocumentSyntaxHighl
598598
{
599599
using var _ = SharpIdeOtel.Source.StartActivity($"{nameof(RoslynAnalysis)}.{nameof(GetDocumentSyntaxHighlighting)}");
600600
await _solutionLoadedTcs.Task;
601-
var project = GetProjectForSharpIdeFile(fileModel);
602601
if (fileModel.IsCsharpFile is false)
603602
{
604603
//throw new InvalidOperationException("File is not a .cs");
605604
return [];
606605
}
607606

607+
var project = GetProjectForSharpIdeFile(fileModel);
608608
var document = project.Documents.Single(s => s.FilePath == fileModel.Path);
609609
Guard.Against.Null(document, nameof(document));
610610

src/SharpIDE.Application/Features/Run/RunService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ public async Task RunProject(SharpIdeProjectModel project, bool isDebug = false,
165165

166166
_logger.LogInformation("Process for project {ProjectName} has exited", project.Name);
167167
}
168+
catch
169+
{
170+
project.RunningCancellationTokenSource?.Dispose();
171+
project.RunningCancellationTokenSource = null;
172+
project.ProjectRunFailed.InvokeParallelFireAndForget();
173+
throw;
174+
}
168175
finally
169176
{
170177
semaphoreSlim.Release();

src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/ProjectContextMenu.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ private void OpenContextMenuProject(SharpIdeProjectModel project)
4444
createNewSubmenu.AddItem("Directory", (int)CreateNewSubmenuOptions.Directory);
4545
createNewSubmenu.AddItem("C# File", (int)CreateNewSubmenuOptions.CSharpFile);
4646
createNewSubmenu.IdPressed += id => OnCreateNewSubmenuPressed(id, project);
47-
48-
menu.AddIconItem(_runIcon, "Run", (int)ProjectContextMenuOptions.Run);
49-
menu.SetItemIconMaxWidth((int)ProjectContextMenuOptions.Run, 20);
50-
menu.AddSeparator();
47+
48+
if (project is { IsLoaded: true, IsRunnable: true })
49+
{
50+
menu.AddIconItem(_runIcon, "Run", (int)ProjectContextMenuOptions.Run);
51+
menu.SetItemIconMaxWidth(menu.GetItemIndex((int)ProjectContextMenuOptions.Run), 20);
52+
menu.AddSeparator();
53+
}
54+
5155
menu.AddItem("Build", (int)ProjectContextMenuOptions.Build);
5256
menu.AddItem("Rebuild", (int)ProjectContextMenuOptions.Rebuild);
5357
menu.AddItem("Clean", (int)ProjectContextMenuOptions.Clean);

0 commit comments

Comments
 (0)