Skip to content

Commit

Permalink
feat(appwindow): add hint for wrong snippet name (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
ouuan authored and coder3101 committed Jan 10, 2020
1 parent cca9c04 commit 1823f00
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/appwindow.cpp
Expand Up @@ -541,18 +541,25 @@ void AppWindow::on_actionUse_Snippets_triggered()
auto names = settingManager->getSnippetsNames(lang);
if (names.isEmpty())
{
activeLogger->warn("Snippets", "There are no snippets for " + lang.toStdString()
+ ". Please add snippets in the preference window.");
activeLogger->warn("Snippets", "There are no snippets for " + lang.toStdString() +
". Please add snippets in the preference window.");
}
else
{
auto ok = new bool;
auto name = QInputDialog::getItem(this, tr("Use Snippets"),
tr("Choose a snippet:"), names, 0, true, ok);
auto name = QInputDialog::getItem(this, tr("Use Snippets"), tr("Choose a snippet:"), names, 0, true, ok);
if (*ok)
{
auto content = settingManager->getSnippet(lang, name);
current->insertText(content);
if (names.contains(name))
{
auto content = settingManager->getSnippet(lang, name);
current->insertText(content);
}
else
{
activeLogger->warn("Snippets", "There is no snippet named " + name.toStdString() + " for " +
lang.toStdString());
}
}
}
}
Expand Down

0 comments on commit 1823f00

Please sign in to comment.