Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions components/finsh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,33 @@ static void finsh_thread_entry(void *parameter)
shell->line_curpos ++;
}

continue;
}
else if (ch == 0x33) /* delete key */
{
/* note that shell->line_curpos >= 0 */
if (shell->line_curpos < 0)
continue;

if (shell->line_position > shell->line_curpos)
{
rt_kprintf("%c", shell->line[shell->line_curpos]);
Copy link
Preview

Copilot AI Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delete key handler currently prints the character at the cursor, which may lead to unexpected output on the console. Consider removing or revising this output to correctly reflect the deletion.

Suggested change
rt_kprintf("%c", shell->line[shell->line_curpos]);

Copilot uses AI. Check for mistakes.

shell->line_position--;

int i;

rt_memmove(&shell->line[shell->line_curpos],
&shell->line[shell->line_curpos + 1],
shell->line_position - shell->line_curpos);
shell->line[shell->line_position] = 0;

rt_kprintf("\b%s \b", &shell->line[shell->line_curpos]);

/* move the cursor to the origin position */
for (i = shell->line_curpos; i <= shell->line_position; i++)
rt_kprintf("\b");
}

continue;
}
}
Expand Down