mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-11-04 12:51:48 +00:00
Be a more patient with Visual Studio when moving the cursor
This commit is contained in:
@@ -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.
|
/// Runs on its own worker thread so the editor never blocks on a busy or starting Visual Studio.
|
||||||
class DteOpenRequest
|
class DteOpenRequest
|
||||||
{
|
{
|
||||||
private const int ColdStartMaxPolls = 120;
|
|
||||||
private const int ColdStartPollIntervalMs = 500;
|
|
||||||
|
|
||||||
private append String _solutionPath = .();
|
private append String _solutionPath = .();
|
||||||
private append String _devenvPath = .();
|
private append String _devenvPath = .();
|
||||||
private append String _fileName = .();
|
private append String _fileName = .();
|
||||||
@@ -108,9 +105,9 @@ class DteOpenRequest
|
|||||||
|
|
||||||
// Wait for the new instance to finish loading the solution (Solution.FullName stays empty
|
// Wait for the new instance to finish loading the solution (Solution.FullName stays empty
|
||||||
// until then), then open the file in it.
|
// 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))
|
if (VisualStudioDte.FindRunningInstance(SolutionPath) case .Ok(let startedDte))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ namespace GlitchyEditor.CodeEditors;
|
|||||||
/// All methods must be called from a thread that is initialized for COM (CoInitializeEx).
|
/// All methods must be called from a thread that is initialized for COM (CoInitializeEx).
|
||||||
static class VisualStudioDte
|
static class VisualStudioDte
|
||||||
{
|
{
|
||||||
|
public const int MaxPolls = 120;
|
||||||
|
public const int PollIntervalMs = 500;
|
||||||
|
|
||||||
private const String MonikerPrefix = "!VisualStudio.DTE";
|
private const String MonikerPrefix = "!VisualStudio.DTE";
|
||||||
/// EnvDTE.Constants.vsViewKindCode
|
/// EnvDTE.Constants.vsViewKindCode
|
||||||
private const String ViewKindCode = "{7651A701-06E5-11D1-8EBD-00A0C90F26EA}";
|
private const String ViewKindCode = "{7651A701-06E5-11D1-8EBD-00A0C90F26EA}";
|
||||||
@@ -204,12 +207,12 @@ static class VisualStudioDte
|
|||||||
defer { delete document; }
|
defer { delete document; }
|
||||||
|
|
||||||
// Directly after OpenFile the ActiveDocument might not be set yet, so retry for a bit.
|
// 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))
|
if (dte.GetObjectProperty("ActiveDocument") case .Ok(out document))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(PollIntervalMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document == null)
|
if (document == null)
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace GlitchyEditor.CodeEditors;
|
namespace GlitchyEditor.CodeEditors;
|
||||||
|
|
||||||
interface IIdeAdapter
|
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);
|
void OpenScript(StringView fileName, int lineNumber = 0, int columnNumber = 0);
|
||||||
|
|
||||||
|
/// Opens the current script solution in the IDE.
|
||||||
void OpenScriptProject();
|
void OpenScriptProject();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user