set selected tab
This commit is contained in:
@@ -34,13 +34,15 @@ public partial class CodeEditorPanel : MarginContainer
|
|||||||
|
|
||||||
public override void _ExitTree()
|
public override void _ExitTree()
|
||||||
{
|
{
|
||||||
|
var selectedTabIndex = _tabContainer.CurrentTab;
|
||||||
var thisSolution = Singletons.AppState.RecentSlns.Single(s => s.FilePath == Solution.FilePath);
|
var thisSolution = Singletons.AppState.RecentSlns.Single(s => s.FilePath == Solution.FilePath);
|
||||||
thisSolution.IdeSolutionState.OpenTabs = _tabContainer.GetChildren().OfType<SharpIdeCodeEdit>()
|
thisSolution.IdeSolutionState.OpenTabs = _tabContainer.GetChildren().OfType<SharpIdeCodeEdit>()
|
||||||
.Select(t => new OpenTab
|
.Select((t, index) => new OpenTab
|
||||||
{
|
{
|
||||||
FilePath = t.SharpIdeFile.Path,
|
FilePath = t.SharpIdeFile.Path,
|
||||||
CaretLine = t.GetCaretLine(),
|
CaretLine = t.GetCaretLine(),
|
||||||
CaretColumn = t.GetCaretColumn()
|
CaretColumn = t.GetCaretColumn(),
|
||||||
|
IsSelected = index == selectedTabIndex
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@@ -103,8 +105,7 @@ public partial class CodeEditorPanel : MarginContainer
|
|||||||
}).AddTo(newTab); // needs to be on ui thread
|
}).AddTo(newTab); // needs to be on ui thread
|
||||||
});
|
});
|
||||||
|
|
||||||
await newTab.SetSharpIdeFile(file);
|
await newTab.SetSharpIdeFile(file, fileLinePosition);
|
||||||
if (fileLinePosition is not null) await this.InvokeAsync(() => newTab.SetFileLinePosition(fileLinePosition.Value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnDebuggerExecutionStopped(ExecutionStopInfo executionStopInfo)
|
private async Task OnDebuggerExecutionStopped(ExecutionStopInfo executionStopInfo)
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Ensure not running on UI thread
|
// TODO: Ensure not running on UI thread
|
||||||
public async Task SetSharpIdeFile(SharpIdeFile file)
|
public async Task SetSharpIdeFile(SharpIdeFile file, SharpIdeFileLinePosition? fileLinePosition = null)
|
||||||
{
|
{
|
||||||
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); // get off the UI thread
|
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); // get off the UI thread
|
||||||
_currentFile = file;
|
_currentFile = file;
|
||||||
@@ -345,11 +345,13 @@ public partial class SharpIdeCodeEdit : CodeEdit
|
|||||||
var razorSyntaxHighlighting = _roslynAnalysis.GetRazorDocumentSyntaxHighlighting(_currentFile);
|
var razorSyntaxHighlighting = _roslynAnalysis.GetRazorDocumentSyntaxHighlighting(_currentFile);
|
||||||
var diagnostics = _roslynAnalysis.GetDocumentDiagnostics(_currentFile);
|
var diagnostics = _roslynAnalysis.GetDocumentDiagnostics(_currentFile);
|
||||||
var projectDiagnosticsForFile = _roslynAnalysis.GetProjectDiagnosticsForFile(_currentFile);
|
var projectDiagnosticsForFile = _roslynAnalysis.GetProjectDiagnosticsForFile(_currentFile);
|
||||||
|
await readFileTask;
|
||||||
var setTextTask = this.InvokeAsync(async () =>
|
var setTextTask = this.InvokeAsync(async () =>
|
||||||
{
|
{
|
||||||
_fileChangingSuppressBreakpointToggleEvent = true;
|
_fileChangingSuppressBreakpointToggleEvent = true;
|
||||||
SetText(await readFileTask);
|
SetText(await readFileTask);
|
||||||
_fileChangingSuppressBreakpointToggleEvent = false;
|
_fileChangingSuppressBreakpointToggleEvent = false;
|
||||||
|
if (fileLinePosition is not null) SetFileLinePosition(fileLinePosition.Value);
|
||||||
});
|
});
|
||||||
await Task.WhenAll(syntaxHighlighting, razorSyntaxHighlighting, setTextTask); // Text must be set before setting syntax highlighting
|
await Task.WhenAll(syntaxHighlighting, razorSyntaxHighlighting, setTextTask); // Text must be set before setting syntax highlighting
|
||||||
await this.InvokeAsync(async () => SetSyntaxHighlightingModel(await syntaxHighlighting, await razorSyntaxHighlighting));
|
await this.InvokeAsync(async () => SetSyntaxHighlightingModel(await syntaxHighlighting, await razorSyntaxHighlighting));
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ public class OpenTab
|
|||||||
public required string FilePath { get; set; }
|
public required string FilePath { get; set; }
|
||||||
public required int CaretLine { get; set; }
|
public required int CaretLine { get; set; }
|
||||||
public required int CaretColumn { get; set; }
|
public required int CaretColumn { get; set; }
|
||||||
|
public required bool IsSelected { get; set; }
|
||||||
}
|
}
|
||||||
@@ -153,14 +153,19 @@ public partial class IdeRoot : Control
|
|||||||
|
|
||||||
var previousTabs = Singletons.AppState.RecentSlns.Single(s => s.FilePath == solutionModel.FilePath).IdeSolutionState.OpenTabs;
|
var previousTabs = Singletons.AppState.RecentSlns.Single(s => s.FilePath == solutionModel.FilePath).IdeSolutionState.OpenTabs;
|
||||||
var filesToOpen = previousTabs
|
var filesToOpen = previousTabs
|
||||||
.Select(s => (solutionModel.AllFiles.Single(f => f.Path == s.FilePath), new SharpIdeFileLinePosition(s.CaretLine, s.CaretColumn)))
|
.Select(s => (solutionModel.AllFiles.Single(f => f.Path == s.FilePath), new SharpIdeFileLinePosition(s.CaretLine, s.CaretColumn), s.IsSelected))
|
||||||
.ToList();
|
.ToList();
|
||||||
await this.InvokeDeferredAsync(async () =>
|
await this.InvokeDeferredAsync(async () =>
|
||||||
{
|
{
|
||||||
foreach (var (file, linePosition) in filesToOpen)
|
// Preserves order of tabs
|
||||||
|
foreach (var (file, linePosition, isSelected) in filesToOpen)
|
||||||
{
|
{
|
||||||
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, linePosition);
|
GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(file, linePosition);
|
||||||
|
await Task.Delay(10).ConfigureAwait(false); // TODO: Do this properly - use InvokeParallelAsync, and fix FileExternallySelected waiting on syntax highlighting etc before returning
|
||||||
}
|
}
|
||||||
|
// Select the selected tab
|
||||||
|
var selectedFile = filesToOpen.SingleOrDefault(f => f.IsSelected);
|
||||||
|
if (selectedFile.Item1 is not null) GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(selectedFile.Item1, selectedFile.Item2);
|
||||||
});
|
});
|
||||||
|
|
||||||
var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList();
|
var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList();
|
||||||
|
|||||||
Reference in New Issue
Block a user