From 20771de512feb5e9f2425f7ec14461e32533e45d Mon Sep 17 00:00:00 2001 From: kelson42 Date: Wed, 15 Aug 2012 18:58:31 +0000 Subject: [PATCH] + small fix in suggestions --- src/server/kiwix-serve.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index f4677f0..6e4480f 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -231,13 +231,26 @@ static int accessHandlerCallback(void *cls, suggestionCount++; } - /* Try to get further suggestions with ucFirst(pattern )if maxSuggestionCount is not reached */ - term = kiwix::ucFirst(term); - reader->searchSuggestions(term, maxSuggestionCount); - while (reader->getNextSuggestion(suggestion)) { - content += (content == "[" ? "" : ","); - content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; - suggestionCount++; + /* Try to get further suggestions with ucFirst(pattern) if maxSuggestionCount is not reached */ + if (suggestionCount < 10) { + term = kiwix::ucFirst(term); + reader->searchSuggestions(term, maxSuggestionCount); + while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) { + content += (content == "[" ? "" : ","); + content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; + suggestionCount++; + } + } + + /* Try to get further suggestions with lcFirst(pattern) if maxSuggestionCount is not reached */ + if (suggestionCount < 10) { + term = kiwix::lcFirst(term); + reader->searchSuggestions(term, maxSuggestionCount); + while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) { + content += (content == "[" ? "" : ","); + content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; + suggestionCount++; + } } content += (suggestionCount == 0 ? "" : ",");