diff --git a/src/article_maker.cc b/src/article_maker.cc index 6508bcba..9ce0ff4f 100644 --- a/src/article_maker.cc +++ b/src/article_maker.cc @@ -282,20 +282,16 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor( QString const & bool ignoreDiacritics ) const { if ( !dictIDs.isEmpty() ) { - QStringList ids = dictIDs; - std::vector< sptr< Dictionary::Class > > ftsDicts; + std::vector< sptr< Dictionary::Class > > dicts; // Find dictionaries by ID's - for ( unsigned x = 0; x < dictionaries.size(); x++ ) { - for ( QStringList::Iterator it = ids.begin(); it != ids.end(); ++it ) { - if ( *it == QString::fromStdString( dictionaries[ x ]->getId() ) ) { - ftsDicts.push_back( dictionaries[ x ] ); - ids.erase( it ); + for ( const auto & dictId : dictIDs ) { + for ( unsigned x = 0; x < dictionaries.size(); x++ ) { + if ( dictId == QString::fromStdString( dictionaries[ x ]->getId() ) ) { + dicts.push_back( dictionaries[ x ] ); break; } } - if ( ids.isEmpty() ) - break; } string header = makeHtmlHeader( word, QString(), true ); @@ -303,7 +299,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor( QString const & return std::make_shared< ArticleRequest >( word, Instances::Group{ groupId, "" }, contexts, - ftsDicts, + dicts, header, -1, true ); diff --git a/src/dictzip.c b/src/dictzip.c index 51b26586..60496075 100644 --- a/src/dictzip.c +++ b/src/dictzip.c @@ -371,8 +371,10 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header if ( pt == buffer + sizeof( buffer ) ) { err_fatal( __func__, "too long FNAME field in dzip file \"%s\"\n", filename ); fclose( str ); - if ( header->chunks ) + if ( header->chunks ) { free( header->chunks ); + header->chunks = NULL; + } return DZ_ERR_INVALID_FORMAT; } } @@ -393,8 +395,10 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header if ( pt == buffer + sizeof( buffer ) ) { err_fatal( __func__, "too long COMMENT field in dzip file \"%s\"\n", filename ); fclose( str ); - if ( header->chunks ) + if ( header->chunks ) { free( header->chunks ); + header->chunks = NULL; + } return DZ_ERR_INVALID_FORMAT; } } @@ -416,8 +420,10 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header if ( ftell( str ) != header->headerLength + 1 ) { err_internal( __func__, "File position (%lu) != header length + 1 (%d)\n", ftell( str ), header->headerLength + 1 ); fclose( str ); - if ( header->chunks ) + if ( header->chunks ) { free( header->chunks ); + header->chunks = NULL; + } return DZ_ERR_INVALID_FORMAT; } @@ -435,8 +441,11 @@ static enum DZ_ERRORS dict_read_header( const char * filename, dictData * header /* Compute offsets */ header->offsets = xmalloc( sizeof( header->offsets[ 0 ] ) * header->chunkCount ); if ( header->offsets == 0 ) { - if ( header->chunks ) + if ( header->chunks ) { free( header->chunks ); + header->chunks = NULL; + } + fclose( str ); return DZ_ERR_NOMEMORY; } diff --git a/src/ui/articleview.cc b/src/ui/articleview.cc index 08faee3f..8e30bfaf 100644 --- a/src/ui/articleview.cc +++ b/src/ui/articleview.cc @@ -2111,10 +2111,18 @@ void ArticleView::highlightFTSResults() webview->page()->runJavaScript( script ); auto parts = regString.split( " ", Qt::SkipEmptyParts ); - if ( !parts.isEmpty() ) { - firstAvailableText = parts[ 0 ]; - ftsSearchPanel->show(); + if ( parts.isEmpty() ) { + return; } + + //hold the longest word + for ( auto & p : parts ) { + if ( p.size() > firstAvailableText.size() ) { + firstAvailableText = p; + } + } + + ftsSearchPanel->show(); } void ArticleView::setActiveDictIds( const ActiveDictIds & ad ) diff --git a/website/docs/topic_move_index_folder.md b/website/docs/topic_move_index_folder.md new file mode 100644 index 00000000..59617d44 --- /dev/null +++ b/website/docs/topic_move_index_folder.md @@ -0,0 +1,17 @@ +How to move the default index folder to other places? + + +## Windows + +!!! note + the [`mklink`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink#related-links) is built-in tool in Windows. + + +1. Open `cmd` as administrator +2. copy the index folder to another place,take `D:\gd-ng\index_new` for example. +3. Run `mklink /D "C:\Users\USERNAME\Application Data\GoldenDict\index" "D:\gd-ng\index_new"` +4. Run GoldenDict + +## Linux + +use `ln` to create a link. diff --git a/website/mkdocs.yml b/website/mkdocs.yml index ed69f837..c7aecc4a 100644 --- a/website/mkdocs.yml +++ b/website/mkdocs.yml @@ -46,6 +46,7 @@ nav: - Wayland: topic_wayland.md - Debug dictionary JS: howto/how to debug dictionary js.md - Flatpak/FlatHub: topic_flatpak.md + - Move index folder: topic_move_index_folder.md - Related tools: - Anki Integration: topic_anki.md - OCR Integration: howto/ocr.md