display symbol lookup popup at mouse
This commit is contained in:
@@ -19,13 +19,11 @@ public partial class SharpIdeCodeEdit
|
||||
{
|
||||
if (HasFocus() is false)
|
||||
return; // only show if we have focus, every tab is currently listening for this event, maybe find a better way
|
||||
var globalMousePosition =
|
||||
GetGlobalMousePosition(); // don't breakpoint before this, else your mouse position will be wrong
|
||||
var globalMousePosition = GetGlobalMousePosition(); // don't breakpoint before this, else your mouse position will be wrong
|
||||
var lineHeight = GetLineHeight();
|
||||
GD.Print($"Symbol hovered: {symbol} at line {line}, column {column}");
|
||||
|
||||
var (roslynSymbol, linePositionSpan) =
|
||||
await _roslynAnalysis.LookupSymbol(_currentFile, new LinePosition((int)line, (int)column));
|
||||
var (roslynSymbol, linePositionSpan) = await _roslynAnalysis.LookupSymbol(_currentFile, new LinePosition((int)line, (int)column));
|
||||
if (roslynSymbol is null || linePositionSpan is null)
|
||||
{
|
||||
return;
|
||||
@@ -47,10 +45,8 @@ public partial class SharpIdeCodeEdit
|
||||
// To debug location, make type a PopupPanel, and uncomment
|
||||
//symbolNameHoverWindow.AddThemeStyleboxOverride("panel", new StyleBoxFlat { BgColor = new Color(1, 0, 0, 0.5f) });
|
||||
|
||||
var startSymbolCharRect =
|
||||
GetRectAtLineColumn(linePositionSpan.Value.Start.Line, linePositionSpan.Value.Start.Character + 1);
|
||||
var endSymbolCharRect =
|
||||
GetRectAtLineColumn(linePositionSpan.Value.End.Line, linePositionSpan.Value.End.Character);
|
||||
var startSymbolCharRect = GetRectAtLineColumn(linePositionSpan.Value.Start.Line, linePositionSpan.Value.Start.Character + 1);
|
||||
var endSymbolCharRect = GetRectAtLineColumn(linePositionSpan.Value.End.Line, linePositionSpan.Value.End.Character);
|
||||
symbolNameHoverWindow.Size = new Vector2I(endSymbolCharRect.End.X - startSymbolCharRect.Position.X, lineHeight);
|
||||
|
||||
var globalPosition = GetGlobalPosition();
|
||||
|
||||
@@ -13,6 +13,11 @@ public partial class SharpIdeCodeEdit
|
||||
private void OnSymbolLookup(string symbolString, long line, long 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 () =>
|
||||
{
|
||||
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(() =>
|
||||
{
|
||||
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