display symbol lookup popup at mouse
This commit is contained in:
@@ -19,13 +19,11 @@ public partial class SharpIdeCodeEdit
|
|||||||
{
|
{
|
||||||
if (HasFocus() is false)
|
if (HasFocus() is false)
|
||||||
return; // only show if we have focus, every tab is currently listening for this event, maybe find a better way
|
return; // only show if we have focus, every tab is currently listening for this event, maybe find a better way
|
||||||
var globalMousePosition =
|
var globalMousePosition = GetGlobalMousePosition(); // don't breakpoint before this, else your mouse position will be wrong
|
||||||
GetGlobalMousePosition(); // don't breakpoint before this, else your mouse position will be wrong
|
|
||||||
var lineHeight = GetLineHeight();
|
var lineHeight = GetLineHeight();
|
||||||
GD.Print($"Symbol hovered: {symbol} at line {line}, column {column}");
|
GD.Print($"Symbol hovered: {symbol} at line {line}, column {column}");
|
||||||
|
|
||||||
var (roslynSymbol, linePositionSpan) =
|
var (roslynSymbol, linePositionSpan) = await _roslynAnalysis.LookupSymbol(_currentFile, new LinePosition((int)line, (int)column));
|
||||||
await _roslynAnalysis.LookupSymbol(_currentFile, new LinePosition((int)line, (int)column));
|
|
||||||
if (roslynSymbol is null || linePositionSpan is null)
|
if (roslynSymbol is null || linePositionSpan is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -47,10 +45,8 @@ public partial class SharpIdeCodeEdit
|
|||||||
// To debug location, make type a PopupPanel, and uncomment
|
// To debug location, make type a PopupPanel, and uncomment
|
||||||
//symbolNameHoverWindow.AddThemeStyleboxOverride("panel", new StyleBoxFlat { BgColor = new Color(1, 0, 0, 0.5f) });
|
//symbolNameHoverWindow.AddThemeStyleboxOverride("panel", new StyleBoxFlat { BgColor = new Color(1, 0, 0, 0.5f) });
|
||||||
|
|
||||||
var startSymbolCharRect =
|
var startSymbolCharRect = GetRectAtLineColumn(linePositionSpan.Value.Start.Line, linePositionSpan.Value.Start.Character + 1);
|
||||||
GetRectAtLineColumn(linePositionSpan.Value.Start.Line, linePositionSpan.Value.Start.Character + 1);
|
var endSymbolCharRect = GetRectAtLineColumn(linePositionSpan.Value.End.Line, linePositionSpan.Value.End.Character);
|
||||||
var endSymbolCharRect =
|
|
||||||
GetRectAtLineColumn(linePositionSpan.Value.End.Line, linePositionSpan.Value.End.Character);
|
|
||||||
symbolNameHoverWindow.Size = new Vector2I(endSymbolCharRect.End.X - startSymbolCharRect.Position.X, lineHeight);
|
symbolNameHoverWindow.Size = new Vector2I(endSymbolCharRect.End.X - startSymbolCharRect.Position.X, lineHeight);
|
||||||
|
|
||||||
var globalPosition = GetGlobalPosition();
|
var globalPosition = GetGlobalPosition();
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ public partial class SharpIdeCodeEdit
|
|||||||
private void OnSymbolLookup(string symbolString, long line, long column)
|
private void OnSymbolLookup(string symbolString, long line, long column)
|
||||||
{
|
{
|
||||||
GD.Print($"Symbol lookup requested: {symbolString} at line {line}, column {column}");
|
GD.Print($"Symbol lookup requested: {symbolString} at line {line}, column {column}");
|
||||||
|
var globalMousePosition = GetGlobalMousePosition(); // don't breakpoint before this, else your mouse position will be wrong
|
||||||
|
var clickedCharRect = GetRectAtLineColumn((int)line, (int)column);
|
||||||
|
var globalPosition = GetGlobalPosition();
|
||||||
|
var startSymbolCharGlobalPos = clickedCharRect.Position + globalPosition;
|
||||||
|
|
||||||
_ = Task.GodotRun(async () =>
|
_ = Task.GodotRun(async () =>
|
||||||
{
|
{
|
||||||
var (symbol, linePositionSpan, semanticInfo) = await _roslynAnalysis.LookupSymbolSemanticInfo(_currentFile, new LinePosition((int)line, (int)column));
|
var (symbol, linePositionSpan, semanticInfo) = await _roslynAnalysis.LookupSymbolSemanticInfo(_currentFile, new LinePosition((int)line, (int)column));
|
||||||
@@ -56,7 +61,10 @@ public partial class SharpIdeCodeEdit
|
|||||||
await this.InvokeAsync(() =>
|
await this.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
AddChild(symbolLookupPopup);
|
AddChild(symbolLookupPopup);
|
||||||
symbolLookupPopup.PopupCentered();
|
symbolLookupPopup.Position = new Vector2I((int)globalMousePosition.X - 5, (int)startSymbolCharGlobalPos.Y);
|
||||||
|
symbolLookupPopup.Popup();
|
||||||
|
var currentMousePos = GetGlobalMousePosition();
|
||||||
|
Input.WarpMouse(currentMousePos with {X = currentMousePos.X + 1}); // it seems that until the mouse moves, behind the popup can still receive mouse events, which causes symbol the hover symbol popup to appear.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user