Skip to content

Commit

Permalink
feat: deselect quick highlighters on same shortcut (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
variar committed Jul 25, 2021
1 parent fb509d2 commit cac0afe
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/ui/src/crawlerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@

#include "configuration.h"
#include "dispatch_to.h"
#include "infoline.h"
#include "fontutils.h"
#include "infoline.h"
#include "overview.h"
#include "quickfindpattern.h"
#include "quickfindwidget.h"
Expand Down Expand Up @@ -1219,7 +1219,20 @@ void CrawlerWidget::registerShortcuts()
} );

const auto addColorLabelToSelection = [ this ]( size_t label ) {
std::get<0>( wordsHighlighters_[ label ] ).append( getSelectedText() );
auto& wordsHighlighters = std::get<0>( wordsHighlighters_[ label ] );
auto selectedPattern = getSelectedText();

const auto existingPattern = std::find_if(
wordsHighlighters.begin(), wordsHighlighters.end(),
[ &selectedPattern ]( const auto& pattern ) { return selectedPattern == pattern; } );

if ( existingPattern == wordsHighlighters.end() ) {
wordsHighlighters.append( std::move( selectedPattern ) );
}
else {
wordsHighlighters.erase( existingPattern );
}

logMainView_->setWordsHighlighters( wordsHighlighters_ );
filteredView_->setWordsHighlighters( wordsHighlighters_ );
};
Expand Down

0 comments on commit cac0afe

Please sign in to comment.