Skip to content

Commit a60edb3

Browse files
committed
[fix] cursor position in prompt input and key search bar
1 parent 690c4f5 commit a60edb3

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/EtcdTerminal.App/Engine/Prompt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static class Prompt
130130
if (!char.IsControl(key.KeyChar))
131131
{
132132
input.Insert(cursor, key.KeyChar);
133-
RedrawInput(startCol, input.ToString(), cursor);
133+
RedrawInput(startCol, input.ToString(), cursor + 1);
134134
cursor++;
135135
}
136136
break;

src/EtcdTerminal.App/Screens/KeyBrowseScreen.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private async Task MainLoopAsync()
9797
while (true)
9898
{
9999
Render();
100+
SetCursorAfterSearch();
100101

101102
var keyInfo = Console.ReadKey(true);
102103

@@ -380,6 +381,19 @@ private int GetPageItemCount() =>
380381
private int GetTotalPages() =>
381382
_filteredKeys.Count == 0 ? 1 : (int)Math.Ceiling((double)_filteredKeys.Count / PageSize);
382383

384+
private void SetCursorAfterSearch()
385+
{
386+
var col = 2;
387+
388+
if (_searchQuery.Length == 0)
389+
col += 27;
390+
else
391+
col += 3 + _searchQuery.Length;
392+
393+
Console.CursorTop = 4;
394+
Console.CursorLeft = col;
395+
}
396+
383397
private static string TruncateText(string text, int maxLength) =>
384398
text.Length <= maxLength ? text : text[..maxLength] + "...";
385399
}

0 commit comments

Comments
 (0)