diff --git a/GlitchyEditor/src/CodeEditors/EnvDte/DteOpenRequest.bf b/GlitchyEditor/src/CodeEditors/EnvDte/DteOpenRequest.bf index bb5636e..e76203f 100644 --- a/GlitchyEditor/src/CodeEditors/EnvDte/DteOpenRequest.bf +++ b/GlitchyEditor/src/CodeEditors/EnvDte/DteOpenRequest.bf @@ -13,9 +13,6 @@ namespace GlitchyEditor.CodeEditors; /// Runs on its own worker thread so the editor never blocks on a busy or starting Visual Studio. class DteOpenRequest { - private const int ColdStartMaxPolls = 120; - private const int ColdStartPollIntervalMs = 500; - private append String _solutionPath = .(); private append String _devenvPath = .(); private append String _fileName = .(); @@ -108,9 +105,9 @@ class DteOpenRequest // Wait for the new instance to finish loading the solution (Solution.FullName stays empty // until then), then open the file in it. - for (int i < ColdStartMaxPolls) + for (int i < VisualStudioDte.MaxPolls) { - Thread.Sleep(ColdStartPollIntervalMs); + Thread.Sleep(VisualStudioDte.PollIntervalMs); if (VisualStudioDte.FindRunningInstance(SolutionPath) case .Ok(let startedDte)) { diff --git a/GlitchyEditor/src/CodeEditors/EnvDte/VisualStudioDte.bf b/GlitchyEditor/src/CodeEditors/EnvDte/VisualStudioDte.bf index c098de1..2110080 100644 --- a/GlitchyEditor/src/CodeEditors/EnvDte/VisualStudioDte.bf +++ b/GlitchyEditor/src/CodeEditors/EnvDte/VisualStudioDte.bf @@ -14,6 +14,9 @@ namespace GlitchyEditor.CodeEditors; /// All methods must be called from a thread that is initialized for COM (CoInitializeEx). static class VisualStudioDte { + public const int MaxPolls = 120; + public const int PollIntervalMs = 500; + private const String MonikerPrefix = "!VisualStudio.DTE"; /// EnvDTE.Constants.vsViewKindCode private const String ViewKindCode = "{7651A701-06E5-11D1-8EBD-00A0C90F26EA}"; @@ -204,12 +207,12 @@ static class VisualStudioDte defer { delete document; } // Directly after OpenFile the ActiveDocument might not be set yet, so retry for a bit. - for (int i < 50) + for (int i < MaxPolls) { if (dte.GetObjectProperty("ActiveDocument") case .Ok(out document)) break; - Thread.Sleep(100); + Thread.Sleep(PollIntervalMs); } if (document == null) diff --git a/GlitchyEditor/src/CodeEditors/IIdeAdapter.bf b/GlitchyEditor/src/CodeEditors/IIdeAdapter.bf index ef1c199..f9ed9f2 100644 --- a/GlitchyEditor/src/CodeEditors/IIdeAdapter.bf +++ b/GlitchyEditor/src/CodeEditors/IIdeAdapter.bf @@ -1,9 +1,15 @@ using System; + namespace GlitchyEditor.CodeEditors; interface IIdeAdapter { + /// Opens the current script solution and the specified script file in the IDE. Allows to specify a line number and a column that the cursor will be moved to. + /// @param fileName The absolute path to the script file. Can be null to just open the script project (Note: the same thing can be achieved by using @see OpenScriptProject). + /// @param lineNumber The line number that the cursor will be placed at (1-based, so 1 is first line). + /// @param lineNumber The column number that the cursor will be placed at (1-based, so 1 is the start of the line). void OpenScript(StringView fileName, int lineNumber = 0, int columnNumber = 0); + /// Opens the current script solution in the IDE. void OpenScriptProject(); }