mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-01 07:35:02 +03: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
Notes:
sideshowbarker
2024-07-17 22:55:25 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/db34ee357d Pull-request: https://github.com/SerenityOS/serenity/pull/22383
@ -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…
Reference in New Issue
Block a user