forked from SublimeText-Markdown/MarkdownEditing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_page_reference.py
35 lines (26 loc) · 1016 Bytes
/
make_page_reference.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sublime, sublime_plugin
import os, string
try:
from MarkdownEditing.wiki_page import *
except ImportError:
from wiki_page import *
try:
from MarkdownEditing.mdeutils import *
except ImportError:
from mdeutils import *
class MakePageReferenceCommand(MDETextCommand):
def is_visible(self):
"""Return True if cursor is on a wiki page reference."""
for sel in self.view.sel():
scopes = self.view.scope_name(sel.b).split(" ")
if 'meta.link.wiki.markdown' in scopes:
return False
return True
def run(self, edit):
print("Running MakePageReferenceCommand")
wiki_page = WikiPage(self.view)
word_region = wiki_page.select_word_at_cursor()
file_list = wiki_page.find_matching_files(word_region)
wiki_page.make_page_reference(edit, word_region)
if len(file_list) > 1:
wiki_page.show_quick_list(file_list)