diff --git a/version.py b/version.py index 5bf1fbd09f..a485a0527a 100644 --- a/version.py +++ b/version.py @@ -1,2 +1,2 @@ ZULIP_VERSION = "1.5.1+git" -PROVISION_VERSION = '4.13' +PROVISION_VERSION = '4.14' diff --git a/zerver/views/messages.py b/zerver/views/messages.py index e02119bff2..bbefef27d2 100644 --- a/zerver/views/messages.py +++ b/zerver/views/messages.py @@ -298,13 +298,13 @@ class NarrowBuilder(object): def _by_search_pgroonga(self, query, operand, maybe_negate): # type: (Query, str, ConditionTransform) -> Query - match_positions_byte = func.pgroonga.match_positions_byte + match_positions_character = func.pgroonga.match_positions_character query_extract_keywords = func.pgroonga.query_extract_keywords keywords = query_extract_keywords(operand) - query = query.column(match_positions_byte(column("rendered_content"), - keywords).label("content_matches")) - query = query.column(match_positions_byte(column("subject"), - keywords).label("subject_matches")) + query = query.column(match_positions_character(column("rendered_content"), + keywords).label("content_matches")) + query = query.column(match_positions_character(column("subject"), + keywords).label("subject_matches")) condition = column("search_pgroonga").op("@@")(operand) return query.where(maybe_negate(condition)) @@ -338,7 +338,7 @@ class NarrowBuilder(object): # Apparently, the offsets we get from tsearch_extras are counted in # unicode characters, not in bytes, so we do our processing with text, # not bytes. -def highlight_string_text_offsets(text, locs): +def highlight_string(text, locs): # type: (AnyStr, Iterable[Tuple[int, int]]) -> Text string = force_text(text) highlight_start = u'' @@ -355,30 +355,6 @@ def highlight_string_text_offsets(text, locs): result += string[pos:] return result -def highlight_string_bytes_offsets(text, locs): - # type: (AnyStr, Iterable[Tuple[int, int]]) -> Text - string = force_bytes(text) - highlight_start = b'' - highlight_stop = b'' - pos = 0 - result = b'' - for loc in locs: - (offset, length) = loc - result += string[pos:offset] - result += highlight_start - result += string[offset:offset + length] - result += highlight_stop - pos = offset + length - result += string[pos:] - return force_text(result) - -def highlight_string(text, locs): - # type: (AnyStr, Iterable[Tuple[int, int]]) -> Text - if settings.USING_PGROONGA: - return highlight_string_bytes_offsets(text, locs) - else: - return highlight_string_text_offsets(text, locs) - def get_search_fields(rendered_content, subject, content_matches, subject_matches): # type: (Text, Text, Iterable[Tuple[int, int]], Iterable[Tuple[int, int]]) -> Dict[str, Text] return dict(match_content=highlight_string(rendered_content, content_matches),