mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 06:04:57 +00:00
LibLine: Avoid returning reference to cached suggestion
This caused a dangling reference down the line, which lead to funny things like the following: > cd Bui[tab] > cd Bui^@^@ By returning a direct reference to the suggestion in question, we can be sure that the referenced object is alive until the next suggestion cycle.
This commit is contained in:
parent
64616d3997
commit
db34ee357d
1 changed files with 3 additions and 2 deletions
|
@ -76,9 +76,10 @@ void SuggestionManager::previous()
|
|||
|
||||
CompletionSuggestion const& SuggestionManager::suggest()
|
||||
{
|
||||
m_last_shown_suggestion = m_suggestions[m_next_suggestion_index];
|
||||
auto const& suggestion = m_suggestions[m_next_suggestion_index];
|
||||
m_selected_suggestion_index = m_next_suggestion_index;
|
||||
return m_last_shown_suggestion;
|
||||
m_last_shown_suggestion = suggestion;
|
||||
return suggestion;
|
||||
}
|
||||
|
||||
void SuggestionManager::set_current_suggestion_initiation_index(size_t index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue