|
2 | 2 |
|
3 | 3 | import FuzzyFilePath.expression as Context |
4 | 4 | import FuzzyFilePath.common.selection as Selection |
| 5 | +from FuzzyFilePath.completion import resolve_trigger |
| 6 | +import FuzzyFilePath.current_state as state |
| 7 | +import FuzzyFilePath.query as Query |
5 | 8 |
|
6 | 9 |
|
7 | 10 | class FfpShowContextCommand(sublime_plugin.TextCommand): |
8 | | - """ displays the current context, required for debugging and trigger setup """ |
9 | | - |
10 | | - content = None |
11 | | - |
12 | | - def run(self, edit): |
13 | | - context = Context.get_context(self.view) |
14 | | - current_scope = self.view.scope_name(Selection.get_position(self.view)) |
15 | | - |
16 | | - self.content = "<h4>FuzzyFilepath - context evaluation</h4>" |
17 | | - self.add("filepath valid", context.get("valid_needle")) |
18 | | - self.add("context valid", context.get("is_valid")) |
19 | | - self.content += "<br>" |
20 | | - self.add("path", context.get("needle")) |
21 | | - self.add("prefix", context.get("prefix")) |
22 | | - self.add("property", context.get("style")) |
23 | | - self.add("tag", context.get("tagName")) |
24 | | - self.add("word", context.get("word")) |
25 | | - self.content += "<br>" |
26 | | - self.add("scope", current_scope) |
27 | | - |
28 | | - self.show() |
29 | | - |
30 | | - def add(self, label, value): |
31 | | - value = "-" if value is None else value |
32 | | - self.content += "<div><b>" + label + ": </b>" + str(value) + "</div>" |
33 | | - |
34 | | - def show(self): |
35 | | - self.view.show_popup(self.content) |
| 11 | + """ displays the current context, required for debugging and trigger setup """ |
| 12 | + |
| 13 | + content = None |
| 14 | + |
| 15 | + def run(self, edit): |
| 16 | + context = Context.get_context(self.view) |
| 17 | + current_scope = self.view.scope_name(Selection.get_position(self.view)) |
| 18 | + trigger = resolve_trigger(self.view, Query, state.get_view()) |
| 19 | + print("FOUND TRIGGER", trigger) |
| 20 | + |
| 21 | + self.content = "<h4>FuzzyFilepath - context evaluation</h4>" |
| 22 | + self.add("filepath valid", context.get("valid_needle")) |
| 23 | + self.add("context valid", context.get("is_valid")) |
| 24 | + self.content += "<br>" |
| 25 | + self.add("path", context.get("needle")) |
| 26 | + self.add("prefix", context.get("prefix")) |
| 27 | + self.add("property", context.get("style")) |
| 28 | + self.add("tag", context.get("tagName")) |
| 29 | + self.add("word", context.get("word")) |
| 30 | + self.content += "<br>" |
| 31 | + self.add("scope", current_scope) |
| 32 | + self.content += "<br>" |
| 33 | + self.content += "<h5>Trigger</h5>" |
| 34 | + if trigger is False: |
| 35 | + self.content += "no trigger could be found matching the given context" |
| 36 | + else: |
| 37 | + for key in trigger: |
| 38 | + self.add(key, trigger.get(key)) |
| 39 | + |
| 40 | + self.show() |
| 41 | + |
| 42 | + def add(self, label, value): |
| 43 | + value = "-" if value is None else value |
| 44 | + self.content += "<div><b>" + label + ": </b>" + str(value) + "</div>" |
| 45 | + |
| 46 | + def show(self): |
| 47 | + self.view.show_popup(self.content) |
0 commit comments