Platform Linux, affects all platforms.
Terminal software kgx
When performing a command and going back in history to the same command and trying to select an item from the autocompletion menu, the selected/already appended item is removed when any key is pressed after the selection.
Steps to reproduce (with Nushell)
- ls / [enter] # Perform some command
- [up] # Scroll back to the same command
- [tab] # Open the autocompletion menu on 'ls /'
- [enter] # Select the first completion suggestion, doesn't matter
- [any key, g] # Press any key and notice how the selected suggestion disappears.
- ls / [tab] # Try to autocomplete 'ls /' by manually typing it rather than selecting it from the history
- [enter]
- [any key, g] # Notice how the pressed key is appended to the end of the selected completion item.
Steps to reproduce (without Nushell using cargo run --example completions)
- l [enter]
- [up]
- [tab]
- [enter]
- [any key, g] # The input should now correspond to "lg" instead of "loging"
- l [tab]
- [enter]
- [any key, g] # The input should now be "loging"
This bug has persisted for years and it has honestly driven me nuts, especially since I wasn't able to find any way to trigger the bug continuously before I realized that the bug was only able to be triggered if the current command to be autocompleted was selected from the history rather than being typed out manually.
It seems like the error happens in src/engine.rs in the run_edit_commands function, where self.history_cursor.string_at_cursor() returns the copy of line_buffer that hasn't been updated with the new value after having selected the autocompletion entry. Because of this, the line_buffer gets replaced with the older value which didn't contain the selected entry.
I was able to fix this issue in specific and pass all unit test by creating a new line right after the aforementioned string initialization and writing this line:
let string = self.editor.line_buffer().get_buffer().to_string();
i.e. overwriting the string with the updated line_buffer value. I'm unsure if this breaks anything else, especially considering there has been many PRs (#97, #584, #704) reverting and restoring this functionality.
Platform Linux, affects all platforms.
Terminal software kgx
When performing a command and going back in history to the same command and trying to select an item from the autocompletion menu, the selected/already appended item is removed when any key is pressed after the selection.
Steps to reproduce (with Nushell)
Steps to reproduce (without Nushell using cargo run --example completions)
This bug has persisted for years and it has honestly driven me nuts, especially since I wasn't able to find any way to trigger the bug continuously before I realized that the bug was only able to be triggered if the current command to be autocompleted was selected from the history rather than being typed out manually.
It seems like the error happens in src/engine.rs in the run_edit_commands function, where self.history_cursor.string_at_cursor() returns the copy of line_buffer that hasn't been updated with the new value after having selected the autocompletion entry. Because of this, the line_buffer gets replaced with the older value which didn't contain the selected entry.
I was able to fix this issue in specific and pass all unit test by creating a new line right after the aforementioned string initialization and writing this line:
i.e. overwriting the string with the updated line_buffer value. I'm unsure if this breaks anything else, especially considering there has been many PRs (#97, #584, #704) reverting and restoring this functionality.