From e0b3e82cb3cba194a108f5046848433d1f4e0489 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 17 Jun 2020 19:56:30 +0200 Subject: [PATCH] Fix tests --- .../net/osmand/search/core/SearchCoreFactory.java | 4 +++- .../java/net/osmand/search/core/SearchPhrase.java | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java index 138cf9ca01..3eccfaaf1c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java @@ -203,7 +203,9 @@ public class SearchCoreFactory { } } if (!leftUnknownSearchWords.isEmpty() && api != null && api.isSearchAvailable(phrase)) { - SearchPhrase nphrase = phrase.selectWord(res, leftUnknownSearchWords, phrase.isLastUnknownSearchWordComplete()); + SearchPhrase nphrase = phrase.selectWord(res, leftUnknownSearchWords, + phrase.isLastUnknownSearchWordComplete() || + !leftUnknownSearchWords.contains(phrase.getLastUnknownSearchWord())); SearchResult prev = resultMatcher.setParentSearchResult(publish ? res : resultMatcher.getParentSearchResult()); api.search(nphrase, resultMatcher); diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java index b7050cd943..7306d2e48d 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java @@ -526,7 +526,7 @@ public class SearchPhrase { public NameStringMatcher getFirstUnknownNameStringMatcher() { if (firstUnknownNameStringMatcher == null) { - firstUnknownNameStringMatcher = getNameStringMatcher(firstUnknownSearchWord, lastUnknownSearchWordComplete); + firstUnknownNameStringMatcher = getNameStringMatcher(firstUnknownSearchWord, isFirstUnknownSearchWordComplete()); } return firstUnknownNameStringMatcher; } @@ -792,6 +792,13 @@ public class SearchPhrase { } return r; } + + public String getLastUnknownSearchWord() { + if(otherUnknownWords.size() > 0) { + return otherUnknownWords.get(otherUnknownWords.size() - 1); + } + return firstUnknownSearchWord; + } public int getRadiusSearch(int meters, int radiusLevel) { @@ -877,4 +884,6 @@ public class SearchPhrase { + + }