This leaves clearing current command line as default behavior which is sane. However, this change adds a parameter clearCommand to the sendInput() method to override this behavior. Inserting the file name and pasting are the scenarios where it is actually undesirable to clear the current command.
Inserting file name (Ctrl+Enter) shouldn't clear command line, both when the focus is inside the terminal and on the file list. Same should go for pasting text (Ctrl+V inside the terminal). The automatic cd command sent when current directory changes in the list should still clear command line (bug 328068 should not regress).