Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix username tab completion without @ #4853

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- Dev: Refactor `Image` & Image's `Frames`. (#4773)
- Dev: Add `WindowManager::getLastSelectedWindow()` to replace `getMainWindow()`. (#4816)
- Dev: Clarify signal connection lifetimes where applicable. (#4818)
- Dev: Laid the groundwork for advanced input completion strategies. (#4639, #4846)
- Dev: Laid the groundwork for advanced input completion strategies. (#4639, #4846, #4853)
- Dev: Fixed flickering when running with Direct2D on Windows. (#4851)

## 2.4.6
Expand Down
11 changes: 7 additions & 4 deletions src/controllers/completion/TabCompletionModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ std::unique_ptr<completion::Source> TabCompletionModel::buildSource(
return this->buildEmoteSource();
}
case SourceKind::User: {
return this->buildUserSource();
return this->buildUserSource(true); // Completing with @
}
case SourceKind::Command: {
return this->buildCommandSource();
Expand All @@ -116,7 +116,8 @@ std::unique_ptr<completion::Source> TabCompletionModel::buildSource(
case SourceKind::EmoteUserCommand: {
std::vector<std::unique_ptr<completion::Source>> sources;
sources.push_back(this->buildEmoteSource());
sources.push_back(this->buildUserSource());
sources.push_back(
this->buildUserSource(false)); // Not completing with @
sources.push_back(this->buildCommandSource());

return std::make_unique<completion::UnifiedSource>(
Expand All @@ -134,10 +135,12 @@ std::unique_ptr<completion::Source> TabCompletionModel::buildEmoteSource() const
std::make_unique<completion::ClassicTabEmoteStrategy>());
}

std::unique_ptr<completion::Source> TabCompletionModel::buildUserSource() const
std::unique_ptr<completion::Source> TabCompletionModel::buildUserSource(
bool prependAt) const
{
return std::make_unique<completion::UserSource>(
&this->channel_, std::make_unique<completion::ClassicUserStrategy>());
&this->channel_, std::make_unique<completion::ClassicUserStrategy>(),
nullptr, prependAt);
}

std::unique_ptr<completion::Source> TabCompletionModel::buildCommandSource()
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/completion/TabCompletionModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ class TabCompletionModel : public QStringListModel

private:
enum class SourceKind {
// Known to be an emote, i.e. started with :
Emote,
// Known to be a username, i.e. started with @
User,
// Known to be a command, i.e. started with / or .
Command,
// Emote or command without : or / .
EmoteCommand,
// Emote, user, or command without :, @, / .
EmoteUserCommand
};

Expand All @@ -54,7 +59,7 @@ class TabCompletionModel : public QStringListModel
std::unique_ptr<completion::Source> buildSource(SourceKind kind) const;

std::unique_ptr<completion::Source> buildEmoteSource() const;
std::unique_ptr<completion::Source> buildUserSource() const;
std::unique_ptr<completion::Source> buildUserSource(bool prependAt) const;
std::unique_ptr<completion::Source> buildCommandSource() const;

Channel &channel_;
Expand Down
Loading