MCPcopy
hub / github.com/facelessuser/BracketHighlighter / compare

Method compare

bh_core.py:270–296  ·  view source on GitHub ↗

Compare brackets. This function allows bracket plugins to add additional logic.

(self, first, second, scope_bracket=False)

Source from the content-addressed store, hash-verified

268 return match
269
270 def compare(self, first, second, scope_bracket=False):
271 """Compare brackets. This function allows bracket plugins to add additional logic."""
272
273 if scope_bracket:
274 match = first is not None and second is not None
275 else:
276 match = first.type == second.type
277
278 if not self.rules.check_compare:
279 return match
280
281 if match:
282 if scope_bracket:
283 bracket = self.rules.scopes[first.scope]["brackets"][first.type]
284 else:
285 bracket = self.rules.brackets[first.type]
286 try:
287 if bracket.compare is not None and match:
288 match = bracket.compare(
289 bracket.name,
290 bh_plugin.BracketRegion(first.begin, first.end),
291 bh_plugin.BracketRegion(second.begin, second.end),
292 self.search.get_buffer()
293 )
294 except Exception:
295 log("Plugin Compare Error:\n%s" % str(traceback.format_exc()))
296 return match
297
298 def post_match(self, left, right, center, scope_bracket=False):
299 """

Callers 2

match_scope_bracketsMethod · 0.95
match_bracketsMethod · 0.95

Calls 2

logFunction · 0.85
get_bufferMethod · 0.80

Tested by

no test coverage detected