Skip to content

Commit b8cb248

Browse files
committed
move rename symbol shortcut to _GuiInput
1 parent f9565b2 commit b8cb248

2 files changed

Lines changed: 30 additions & 18 deletions

File tree

src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public partial class SharpIdeCodeEdit : CodeEdit
2727
{
2828
[Signal]
2929
public delegate void CodeFixesRequestedEventHandler();
30-
30+
3131
public SharpIdeSolutionModel? Solution { get; set; }
3232
public SharpIdeFile SharpIdeFile => _currentFile;
3333
private SharpIdeFile _currentFile = null!;
34-
34+
3535
private CustomHighlighter _syntaxHighlighter = new();
3636
private PopupMenu _popupMenu = null!;
3737
private CanvasItem _aboveCanvasItem = null!;
@@ -111,7 +111,7 @@ public override void _Ready()
111111
GodotGlobalEvents.Instance.TextEditorCodeFoldingChanged.Subscribe(SetCodeFoldingAsync);
112112
SetCodeFolding(Singletons.AppState.IdeSettings.EditorEnableFolding);
113113
}
114-
114+
115115
public override void _Notification(int what)
116116
{
117117
if (what == NotificationThemeChanged)
@@ -217,7 +217,7 @@ public override void _ExitTree()
217217
GodotGlobalEvents.Instance.TextEditorCodeFoldingChanged.Unsubscribe(SetCodeFoldingAsync);
218218
if (_currentFile is not null) _openTabsFileManager.CloseFile(_currentFile);
219219
}
220-
220+
221221
private void OnFocusEntered()
222222
{
223223
// The selected tab changed, report the caret position
@@ -303,7 +303,7 @@ private void OnCodeFixSelected(long id)
303303
GD.Print($"Code fix selected: {id}");
304304
var codeAction = _currentCodeActionsInPopup[(int)id];
305305
if (codeAction is null) return;
306-
306+
307307
_ = Task.GodotRun(async () =>
308308
{
309309
await _ideCodeActionService.ApplyCodeAction(codeAction);
@@ -365,7 +365,7 @@ public async Task SetSharpIdeFile(SharpIdeFile file, SharpIdeFileLinePosition? f
365365
await this.InvokeAsync(() => SetProjectDiagnostics(projectDiagnosticsForFile));
366366
}, configureAwait: false);
367367
}
368-
368+
369369
var syntaxHighlighting = _roslynAnalysis.GetDocumentSyntaxHighlighting(_currentFile);
370370
var razorSyntaxHighlighting = _roslynAnalysis.GetRazorDocumentSyntaxHighlighting(_currentFile);
371371
var diagnostics = _roslynAnalysis.GetDocumentDiagnostics(_currentFile);
@@ -409,13 +409,13 @@ public void UnderlineRange(int line, int caretStartCol, int caretEndCol, Color c
409409
int lineLength = GetLine(line).Length;
410410
caretStartCol = Mathf.Clamp(caretStartCol, 0, lineLength);
411411
caretEndCol = Mathf.Clamp(caretEndCol, 0, lineLength);
412-
412+
413413
// GetRectAtLineColumn returns the rectangle for the character before the column passed in, or the first character if the column is 0.
414414
var startRect = GetRectAtLineColumn(line, caretStartCol);
415415
var endRect = GetRectAtLineColumn(line, caretEndCol);
416416
//DrawLine(startRect.Position, startRect.End, color);
417417
//DrawLine(endRect.Position, endRect.End, color);
418-
418+
419419
var startPos = startRect.End;
420420
if (caretStartCol is 0)
421421
{
@@ -464,15 +464,15 @@ public void DrawLineBackgroundColorCustom(int line, Color color, bool includeLef
464464
public override void _Draw()
465465
{
466466
RenderingServer.Singleton.CanvasItemClear(_aboveCanvasItemRid!.Value);
467-
467+
468468
// Draw a guideline at the left edge of the text area
469469
var gutterWidth = GetTotalGutterWidth();
470470
var leftEdgeStart = new Vector2(gutterWidth, 0);
471471
var leftEdgeEnd = new Vector2(gutterWidth, Size.Y);
472472
RenderingServer.Singleton.CanvasItemAddLine(_aboveCanvasItemRid.Value, leftEdgeStart, leftEdgeEnd, new Color("464646"), 1);
473473

474474
var currentCaretLine = GetCaretLine();
475-
475+
476476
using var nativeInt32ArrayHandle = GetBreakpointedLinesUnmanaged();
477477
foreach (var line in nativeInt32ArrayHandle.Span)
478478
{
@@ -491,7 +491,7 @@ public override void _Draw()
491491
HighlightLineTextRange(line, lineStartCol, lineEndCol, _executingLineColor);
492492
}
493493
}
494-
494+
495495
foreach (var sharpIdeDiagnostic in _fileDiagnostics.Concat(_fileAnalyzerDiagnostics).ConcatFast(_projectDiagnosticsForFile))
496496
{
497497
var line = sharpIdeDiagnostic.Span.Start.Line;
@@ -590,6 +590,12 @@ public override void _GuiInput(InputEvent @event)
590590
MoveLinesDown();
591591
return;
592592
}
593+
if (@event.IsActionPressed(InputStringNames.RenameSymbol))
594+
{
595+
AcceptEvent();
596+
_ = Task.GodotRun(async () => await RenameSymbol());
597+
return;
598+
}
593599
if (@event is InputEventMouseButton { Pressed: true, ButtonIndex: MouseButton.Left or MouseButton.Right } mouseEvent)
594600
{
595601
var (col, line) = GetLineColumnAtPos((Vector2I)mouseEvent.Position);
@@ -627,10 +633,6 @@ public override void _UnhandledKeyInput(InputEvent @event)
627633
AcceptEvent();
628634
_findReplaceBar.PopupReplace();
629635
}
630-
else if (@event.IsActionPressed(InputStringNames.RenameSymbol))
631-
{
632-
_ = Task.GodotRun(async () => await RenameSymbol());
633-
}
634636
else if (@event.IsActionPressed(InputStringNames.CodeFixes))
635637
{
636638
EmitSignalCodeFixesRequested();
@@ -657,14 +659,14 @@ private void SetDiagnostics(ImmutableArray<SharpIdeDiagnostic> diagnostics)
657659
_fileDiagnostics = diagnostics;
658660
QueueRedraw();
659661
}
660-
662+
661663
[RequiresGodotUiThread]
662664
private void SetAnalyzerDiagnostics(ImmutableArray<SharpIdeDiagnostic> diagnostics)
663665
{
664666
_fileAnalyzerDiagnostics = diagnostics;
665667
QueueRedraw();
666668
}
667-
669+
668670
[RequiresGodotUiThread]
669671
private void SetProjectDiagnostics(ImmutableArray<SharpIdeDiagnostic> diagnostics)
670672
{
@@ -710,7 +712,7 @@ await this.InvokeAsync(() =>
710712
});
711713
});
712714
}
713-
715+
714716
private (int line, int col) GetCaretPosition(bool startAt1 = false)
715717
{
716718
var caretColumn = GetCaretColumn();

src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public override void _Ready()
4848
_ = Task.GodotRun(BindToSolution);
4949
}
5050

51+
52+
public override void _ShortcutInput(InputEvent @event)
53+
{
54+
if (@event.IsActionPressed(InputStringNames.RenameSymbol))
55+
{
56+
AcceptEvent();
57+
var selectedTreeItem = _tree.GetSelected();
58+
}
59+
}
60+
5161
public override void _UnhandledKeyInput(InputEvent @event)
5262
{
5363
// Copy

0 commit comments

Comments
 (0)