Skip to content

Commit e2cccac

Browse files
committed
Fixed wrong page flipping command in !!loc search result
resolved #4
1 parent bab7a9d commit e2cccac

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

location_marker/entry.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23
import re
34
from typing import Callable, Any, Optional, Union
@@ -116,6 +117,11 @@ def list_locations(source: CommandSource, *, keyword: Optional[str] = None, page
116117
for loc in matched_locations:
117118
reply_location_as_item(source, loc)
118119
else:
120+
command_base = constants.PREFIX
121+
if keyword is None:
122+
command_base += ' list'
123+
else:
124+
command_base += ' search {}'.format(json.dumps(keyword, ensure_ascii=False))
119125
left, right = (page - 1) * config.item_per_page, page * config.item_per_page
120126
for i in range(left, right):
121127
if 0 <= i < matched_count:
@@ -126,10 +132,10 @@ def list_locations(source: CommandSource, *, keyword: Optional[str] = None, page
126132
color = {False: RColor.dark_gray, True: RColor.gray}
127133
prev_page = RText('<-', color=color[has_prev])
128134
if has_prev:
129-
prev_page.c(RAction.run_command, '{} list {}'.format(constants.PREFIX, page - 1)).h('点击显示上一页')
135+
prev_page.c(RAction.run_command, '{} {}'.format(command_base, page - 1)).h('点击显示上一页')
130136
next_page = RText('->', color=color[has_next])
131137
if has_next:
132-
next_page.c(RAction.run_command, '{} list {}'.format(constants.PREFIX, page + 1)).h('点击显示下一页')
138+
next_page.c(RAction.run_command, '{} {}'.format(command_base, page + 1)).h('点击显示下一页')
133139

134140
source.reply(RTextList(
135141
prev_page,
@@ -243,4 +249,4 @@ def on_load(server: PluginServerInterface, old_inst):
243249
QuotableText('name').runs(lambda src, ctx: show_location_detail(src, ctx['name']))
244250
)
245251
)
246-
)
252+
)

0 commit comments

Comments
 (0)