Skip to content

Commit 8d490ea

Browse files
committed
show number of selected results when applicable
1 parent f52ea1d commit 8d490ea

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

sublime_lxml.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,15 @@ def get_regions_of_nodes(view, nodes, position_type):
134134
yield sublime.Region(open_pos.begin(), close_pos.end())
135135

136136
def move_cursors_to_nodes(view, nodes, position_type):
137+
nodes = list(nodes)
137138
cursors = list(get_regions_of_nodes(view, nodes, position_type))
138139
if len(cursors) > 0:
139140
view.sel().clear()
140141
view.sel().add_all(cursors)
141142

142143
view.show(cursors[0]) # scroll to show the first selection, if it is not already visible
144+
145+
return (len(cursors) == len(nodes), len(cursors))
143146

144147
def getElementXMLPreview(view, node, maxlen):
145148
"""Generate the xml string for the given node, up to the specified number of characters."""

xpath.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,13 @@ def process_results_for_query(self, query):
834834

835835
self.show_results_for_query()
836836
else:
837-
self.goto_results_for_query()
837+
all_success = self.goto_results_for_query()
838+
if not all_success[0]:
839+
status_text += ' (' + str(all_success[1])
838840
status_text += ' selected'
841+
if not all_success[0]:
842+
status_text += ')'
843+
839844
if not self.show_query_results:
840845
sublime.status_message(status_text or '')
841846
else:
@@ -893,10 +898,12 @@ def goto_results_for_query(self, specific_index = None):
893898
if specific_index is not None and specific_index > -1:
894899
results = [results[specific_index]]
895900

896-
move_cursors_to_nodes(self.view, results, 'open')
901+
all_success = move_cursors_to_nodes(self.view, results, 'open')
897902

898903
if specific_index is None or specific_index == -1:
899904
self.results = None
905+
906+
return all_success
900907

901908
def is_enabled(self, **args):
902909
return isCursorInsideSGML(self.view)

0 commit comments

Comments
 (0)