mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-11-04 12:51: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 ColumnNumber;
|
||||
|
||||
private static int32 sWorkerActive = 0;
|
||||
|
||||
@@ -83,7 +84,7 @@ class DteOpenRequest
|
||||
if (FileName.IsEmpty)
|
||||
VisualStudioDte.ActivateMainWindow(dte);
|
||||
else
|
||||
VisualStudioDte.OpenFileAtLine(dte, FileName, LineNumber).IgnoreError();
|
||||
VisualStudioDte.OpenFileAtLine(dte, FileName, LineNumber, ColumnNumber).IgnoreError();
|
||||
|
||||
delete dte;
|
||||
|
||||
@@ -113,7 +114,7 @@ class DteOpenRequest
|
||||
|
||||
if (VisualStudioDte.FindRunningInstance(SolutionPath) case .Ok(let startedDte))
|
||||
{
|
||||
VisualStudioDte.OpenFileAtLine(startedDte, FileName, LineNumber).IgnoreError();
|
||||
VisualStudioDte.OpenFileAtLine(startedDte, FileName, LineNumber, ColumnNumber).IgnoreError();
|
||||
|
||||
delete startedDte;
|
||||
return;
|
||||
|
||||
@@ -107,7 +107,7 @@ static class VisualStudioDte
|
||||
|
||||
/// Opens the given file in the code editor of the given Visual Studio instance and
|
||||
/// 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"));
|
||||
defer delete itemOperations;
|
||||
@@ -125,7 +125,7 @@ static class VisualStudioDte
|
||||
}
|
||||
|
||||
if (lineNumber > 0)
|
||||
GoToLine(dte, lineNumber);
|
||||
GoToLine(dte, lineNumber, columnNumber);
|
||||
|
||||
ActivateMainWindow(dte);
|
||||
|
||||
@@ -198,13 +198,13 @@ static class VisualStudioDte
|
||||
return path;
|
||||
}
|
||||
|
||||
private static void GoToLine(ComDispatch dte, int lineNumber)
|
||||
private static void GoToLine(ComDispatch dte, int lineNumber, int columnNumber)
|
||||
{
|
||||
ComDispatch document = null;
|
||||
defer { delete document; }
|
||||
|
||||
// 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))
|
||||
break;
|
||||
@@ -224,9 +224,14 @@ static class VisualStudioDte
|
||||
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))
|
||||
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);
|
||||
|
||||
delete selection;
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace GlitchyEditor.CodeEditors;
|
||||
|
||||
interface IIdeAdapter
|
||||
{
|
||||
void OpenScript(StringView fileName, int lineNumber = 0);
|
||||
void OpenScript(StringView fileName, int lineNumber = 0, int columnNumber = 0);
|
||||
|
||||
void OpenScriptProject();
|
||||
}
|
||||
|
||||
@@ -21,14 +21,15 @@ class RiderIdeAdapter : IIdeAdapter
|
||||
_ideInstallation = ideInstallation;
|
||||
}
|
||||
|
||||
public void OpenScript(StringView fileName, int lineNumber)
|
||||
public void OpenScript(StringView fileName, int lineNumber, int columnNumber)
|
||||
{
|
||||
String solutionPath = scope .();
|
||||
Editor.Instance.CurrentProject.GetPathToScriptSolutionFile(solutionPath);
|
||||
|
||||
ProcessStartInfo startInfo = scope .();
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ class VisualStudioIdeAdapter : IIdeAdapter
|
||||
_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()
|
||||
{
|
||||
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();
|
||||
Editor.Instance.CurrentProject.GetPathToScriptSolutionFile(solutionPath);
|
||||
@@ -57,6 +57,7 @@ class VisualStudioIdeAdapter : IIdeAdapter
|
||||
request.DevenvPath = _ideInstallation.Path;
|
||||
request.FileName = fileName;
|
||||
request.LineNumber = lineNumber;
|
||||
request.ColumnNumber = columnNumber;
|
||||
|
||||
DteOpenRequest.Start(request);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user