Skip to content

Commit

Permalink
Fixed wrong page flipping command in !!loc search result
Browse files Browse the repository at this point in the history
resolved #4
  • Loading branch information
Fallen-Breath committed Jun 6, 2023
1 parent bab7a9d commit e2cccac
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions location_marker/entry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import re
from typing import Callable, Any, Optional, Union
Expand Down Expand Up @@ -116,6 +117,11 @@ def list_locations(source: CommandSource, *, keyword: Optional[str] = None, page
for loc in matched_locations:
reply_location_as_item(source, loc)
else:
command_base = constants.PREFIX
if keyword is None:
command_base += ' list'
else:
command_base += ' search {}'.format(json.dumps(keyword, ensure_ascii=False))
left, right = (page - 1) * config.item_per_page, page * config.item_per_page
for i in range(left, right):
if 0 <= i < matched_count:
Expand All @@ -126,10 +132,10 @@ def list_locations(source: CommandSource, *, keyword: Optional[str] = None, page
color = {False: RColor.dark_gray, True: RColor.gray}
prev_page = RText('<-', color=color[has_prev])
if has_prev:
prev_page.c(RAction.run_command, '{} list {}'.format(constants.PREFIX, page - 1)).h('点击显示上一页')
prev_page.c(RAction.run_command, '{} {}'.format(command_base, page - 1)).h('点击显示上一页')
next_page = RText('->', color=color[has_next])
if has_next:
next_page.c(RAction.run_command, '{} list {}'.format(constants.PREFIX, page + 1)).h('点击显示下一页')
next_page.c(RAction.run_command, '{} {}'.format(command_base, page + 1)).h('点击显示下一页')

source.reply(RTextList(
prev_page,
Expand Down Expand Up @@ -243,4 +249,4 @@ def on_load(server: PluginServerInterface, old_inst):
QuotableText('name').runs(lambda src, ctx: show_location_detail(src, ctx['name']))
)
)
)
)

0 comments on commit e2cccac

Please sign in to comment.