Skip to content

Commit

Permalink
Code Windows: Go to definition on ctrl+click #686
Browse files Browse the repository at this point in the history
  • Loading branch information
falko17 committed Jul 27, 2024
1 parent ff311ab commit f0db058
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 119 deletions.
3 changes: 2 additions & 1 deletion Assets/SEE/Controls/KeyActions/KeyBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class KeyBindings
{
// IMPORTANT NOTES:
// (1) Keep in mind that KeyCodes in Unity map directly to a
// physical key on an keyboard with an English layout.
// physical key on a keyboard with an English layout.
// (2) Ctrl-Z and Ctrl-Y are reserved for Undo and Redo.
// (3) The digits 0-9 are reserved for shortcuts for the player menu.

Expand All @@ -30,6 +30,7 @@ internal static class KeyBindings

/// <summary>
/// Returns true if the user has pressed down a key requesting the given <paramref name="keyAction"/>
/// in the last frame.
/// </summary>
/// <param name="keyAction">the <see cref="KeyAction"/> to check</param>
/// <returns>true if the user has pressed a key requesting the given <paramref name="keyAction"/></returns>
Expand Down
12 changes: 9 additions & 3 deletions Assets/SEE/UI/Window/CodeWindow/CodeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public partial class CodeWindow : BaseWindow
/// </summary>
private LSPHandler lspHandler;

/// <summary>
/// The handler for the context menu of this code window, which provides various navigation options,
/// such as "Go to Definition" or "Find References".
/// </summary>
private ContextMenuHandler contextMenu;

/// <summary>
/// Path to the code window content prefab.
/// </summary>
Expand Down Expand Up @@ -118,13 +124,14 @@ public void MarkLine(int lineNumber)
.ToArray();
if (lineNumber < 1)
{
textMesh.text = string.Join("\n", allLines);
text = string.Join("\n", allLines);
}
else
{
string markLine = $"{markColor}{allLines[lineNumber - 1][markColorLength..]}";
textMesh.text = string.Join("\n", allLines.Exclude(lineNumber - 1, 1).Insert(new[] { markLine }, lineNumber - 1));
text = string.Join("\n", allLines.Exclude(lineNumber - 1, 1).Insert(new[] { markLine }, lineNumber - 1));
}
textMesh.text = text;
}

#region Visible Line Calculation
Expand Down Expand Up @@ -184,7 +191,6 @@ public int ScrolledVisibleLine
.AppendCallback(() => scrollingTo = 0);

MarkLine(value);

ScrollEvent.Invoke();
}
}
Expand Down
Loading

0 comments on commit f0db058

Please sign in to comment.