mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-11-04 21:01:48 +00:00
Allow jumping to columns in IDE
This commit is contained in:
@@ -40,6 +40,7 @@ class DteOpenRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int LineNumber;
|
public int LineNumber;
|
||||||
|
public int ColumnNumber;
|
||||||
|
|
||||||
private static int32 sWorkerActive = 0;
|
private static int32 sWorkerActive = 0;
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ class DteOpenRequest
|
|||||||
if (FileName.IsEmpty)
|
if (FileName.IsEmpty)
|
||||||
VisualStudioDte.ActivateMainWindow(dte);
|
VisualStudioDte.ActivateMainWindow(dte);
|
||||||
else
|
else
|
||||||
VisualStudioDte.OpenFileAtLine(dte, FileName, LineNumber).IgnoreError();
|
VisualStudioDte.OpenFileAtLine(dte, FileName, LineNumber, ColumnNumber).IgnoreError();
|
||||||
|
|
||||||
delete dte;
|
delete dte;
|
||||||
|
|
||||||
@@ -113,7 +114,7 @@ class DteOpenRequest
|
|||||||
|
|
||||||
if (VisualStudioDte.FindRunningInstance(SolutionPath) case .Ok(let startedDte))
|
if (VisualStudioDte.FindRunningInstance(SolutionPath) case .Ok(let startedDte))
|
||||||
{
|
{
|
||||||
VisualStudioDte.OpenFileAtLine(startedDte, FileName, LineNumber).IgnoreError();
|
VisualStudioDte.OpenFileAtLine(startedDte, FileName, LineNumber, ColumnNumber).IgnoreError();
|
||||||
|
|
||||||
delete startedDte;
|
delete startedDte;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ static class VisualStudioDte
|
|||||||
|
|
||||||
/// Opens the given file in the code editor of the given Visual Studio instance and
|
/// Opens the given file in the code editor of the given Visual Studio instance and
|
||||||
/// jumps to lineNumber (1-based, ignored if <= 0).
|
/// jumps to lineNumber (1-based, ignored if <= 0).
|
||||||
public static Result<void> OpenFileAtLine(ComDispatch dte, StringView fileName, int lineNumber)
|
public static Result<void> OpenFileAtLine(ComDispatch dte, StringView fileName, int lineNumber, int columnNumber)
|
||||||
{
|
{
|
||||||
ComDispatch itemOperations = Try!(dte.GetObjectProperty("ItemOperations"));
|
ComDispatch itemOperations = Try!(dte.GetObjectProperty("ItemOperations"));
|
||||||
defer delete itemOperations;
|
defer delete itemOperations;
|
||||||
@@ -125,7 +125,7 @@ static class VisualStudioDte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lineNumber > 0)
|
if (lineNumber > 0)
|
||||||
GoToLine(dte, lineNumber);
|
GoToLine(dte, lineNumber, columnNumber);
|
||||||
|
|
||||||
ActivateMainWindow(dte);
|
ActivateMainWindow(dte);
|
||||||
|
|
||||||
@@ -198,13 +198,13 @@ static class VisualStudioDte
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GoToLine(ComDispatch dte, int lineNumber)
|
private static void GoToLine(ComDispatch dte, int lineNumber, int columnNumber)
|
||||||
{
|
{
|
||||||
ComDispatch document = null;
|
ComDispatch document = null;
|
||||||
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 < 10)
|
for (int i < 50)
|
||||||
{
|
{
|
||||||
if (dte.GetObjectProperty("ActiveDocument") case .Ok(out document))
|
if (dte.GetObjectProperty("ActiveDocument") case .Ok(out document))
|
||||||
break;
|
break;
|
||||||
@@ -224,9 +224,14 @@ static class VisualStudioDte
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VARIANT[2] gotoLineArgs = .(VARIANT.FromInt32((int32)lineNumber), VARIANT.FromBool(false));
|
/*VARIANT[2] gotoLineArgs = .(VARIANT.FromInt32((int32)lineNumber), VARIANT.FromBool(false));
|
||||||
|
|
||||||
if (selection.InvokeMethod("GotoLine", gotoLineArgs) case .Ok(var gotoResult))
|
if (selection.InvokeMethod("GotoLine", gotoLineArgs) case .Ok(var gotoResult))
|
||||||
|
VariantClear(&gotoResult);*/
|
||||||
|
|
||||||
|
VARIANT[3] gotoLineArgs = .(VARIANT.FromInt32((int32)lineNumber), VARIANT.FromInt32((int32)columnNumber), VARIANT.FromBool(false));
|
||||||
|
|
||||||
|
if (selection.InvokeMethod("MoveTo", gotoLineArgs) case .Ok(var gotoResult))
|
||||||
VariantClear(&gotoResult);
|
VariantClear(&gotoResult);
|
||||||
|
|
||||||
delete selection;
|
delete selection;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ namespace GlitchyEditor.CodeEditors;
|
|||||||
|
|
||||||
interface IIdeAdapter
|
interface IIdeAdapter
|
||||||
{
|
{
|
||||||
void OpenScript(StringView fileName, int lineNumber = 0);
|
void OpenScript(StringView fileName, int lineNumber = 0, int columnNumber = 0);
|
||||||
|
|
||||||
void OpenScriptProject();
|
void OpenScriptProject();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,14 +21,15 @@ class RiderIdeAdapter : IIdeAdapter
|
|||||||
_ideInstallation = ideInstallation;
|
_ideInstallation = ideInstallation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenScript(StringView fileName, int lineNumber)
|
public void OpenScript(StringView fileName, int lineNumber, int columnNumber)
|
||||||
{
|
{
|
||||||
String solutionPath = scope .();
|
String solutionPath = scope .();
|
||||||
Editor.Instance.CurrentProject.GetPathToScriptSolutionFile(solutionPath);
|
Editor.Instance.CurrentProject.GetPathToScriptSolutionFile(solutionPath);
|
||||||
|
|
||||||
ProcessStartInfo startInfo = scope .();
|
ProcessStartInfo startInfo = scope .();
|
||||||
startInfo.SetFileName(_ideInstallation.Path);
|
startInfo.SetFileName(_ideInstallation.Path);
|
||||||
startInfo.SetArguments(scope $"{solutionPath} --line {lineNumber} {fileName}");
|
// For rider columns appear to be 0-indexed
|
||||||
|
startInfo.SetArguments(scope $"\"{solutionPath}\" --line {lineNumber} --column {columnNumber - 1} \"{fileName}\"");
|
||||||
|
|
||||||
scope SpawnedProcess().Start(startInfo);
|
scope SpawnedProcess().Start(startInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ class VisualStudioIdeAdapter : IIdeAdapter
|
|||||||
_ideInstallation = ideInstallation;
|
_ideInstallation = ideInstallation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenScript(StringView fileName, int lineNumber)
|
public void OpenScript(StringView fileName, int lineNumber, int columnNumber)
|
||||||
{
|
{
|
||||||
Open(fileName, lineNumber);
|
Open(fileName, lineNumber, columnNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenScriptProject()
|
public void OpenScriptProject()
|
||||||
{
|
{
|
||||||
Open(null, 0);
|
Open(null, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Open(StringView fileName, int lineNumber)
|
private void Open(StringView fileName, int lineNumber, int columnNumber)
|
||||||
{
|
{
|
||||||
String solutionPath = scope String();
|
String solutionPath = scope String();
|
||||||
Editor.Instance.CurrentProject.GetPathToScriptSolutionFile(solutionPath);
|
Editor.Instance.CurrentProject.GetPathToScriptSolutionFile(solutionPath);
|
||||||
@@ -57,6 +57,7 @@ class VisualStudioIdeAdapter : IIdeAdapter
|
|||||||
request.DevenvPath = _ideInstallation.Path;
|
request.DevenvPath = _ideInstallation.Path;
|
||||||
request.FileName = fileName;
|
request.FileName = fileName;
|
||||||
request.LineNumber = lineNumber;
|
request.LineNumber = lineNumber;
|
||||||
|
request.ColumnNumber = columnNumber;
|
||||||
|
|
||||||
DteOpenRequest.Start(request);
|
DteOpenRequest.Start(request);
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user