@@ -25,6 +25,42 @@ def docset_keys(view, syntax_docset_map):
25
25
return []
26
26
27
27
28
+ def open_dash (query , keys , run_in_background )
29
+ # background
30
+ background_string = '&prevent_activation=true' if run_in_background else ''
31
+
32
+ if platform .system () == 'Windows' :
33
+ # sending keys=<nothing> confuses some Windows doc viewers
34
+ if keys :
35
+ # ampersand must be escaped and ^ is the Windows shell escape char
36
+ url = 'dash-plugin://keys=%s^&query=%s%s' % (',' .join (keys ), quote (query ), background_string )
37
+ else :
38
+ url = 'dash-plugin://query=%s%s' % (quote (query ), background_string )
39
+ subprocess .call (['start' , url ], shell = True )
40
+ elif platform .system () == 'Linux' :
41
+ if keys :
42
+ subprocess .call ([
43
+ '/usr/bin/xdg-open' ,
44
+ 'dash-plugin:keys=%s&query=%s%s' % (',' .join (keys ), quote (query ), background_string )
45
+ ])
46
+ else :
47
+ subprocess .call ([
48
+ '/usr/bin/xdg-open' ,
49
+ 'dash-plugin:query=%s%s' % (quote (query ), background_string )
50
+ ])
51
+ else :
52
+ if keys :
53
+ subprocess .call ([
54
+ '/usr/bin/open' , '-g' ,
55
+ 'dash-plugin://keys=%s&query=%s%s' % (',' .join (keys ), quote (query ), background_string )
56
+ ])
57
+ else :
58
+ subprocess .call ([
59
+ '/usr/bin/open' , '-g' ,
60
+ 'dash-plugin://query=%s%s' % (quote (query ), background_string )
61
+ ])
62
+
63
+
28
64
class DashDocCommand (sublime_plugin .TextCommand ):
29
65
def run (self , edit , flip_syntax_sensitive = False , run_in_background = False ):
30
66
# read global and (project-specific) local settings
@@ -51,23 +87,8 @@ def run(self, edit, flip_syntax_sensitive=False, run_in_background=False):
51
87
syntax_sensitive = flip_syntax_sensitive ^ syntax_sensitive_as_default
52
88
keys = docset_keys (self .view , syntax_docset_map ) if syntax_sensitive else []
53
89
54
- # background
55
- background_string = '&prevent_activation=true' if run_in_background else ''
56
-
57
- if platform .system () == 'Windows' :
58
- # sending keys=<nothing> confuses some Windows doc viewers
59
- if keys :
60
- # ampersand must be escaped and ^ is the Windows shell escape char
61
- url = 'dash-plugin://keys=%s^&query=%s%s' % (',' .join (keys ), quote (query ), background_string )
62
- else :
63
- url = 'dash-plugin://query=%s%s' % (quote (query ), background_string )
64
- subprocess .call (['start' , url ], shell = True )
65
- elif platform .system () == 'Linux' :
66
- subprocess .call (['/usr/bin/xdg-open' ,
67
- 'dash-plugin:keys=%s&query=%s%s' % (',' .join (keys ), quote (query ), background_string )])
68
- else :
69
- subprocess .call (['/usr/bin/open' , '-g' ,
70
- 'dash-plugin://keys=%s&query=%s%s' % (',' .join (keys ), quote (query ), background_string )])
90
+ open_dash (query , keys , run_in_background )
91
+
71
92
72
93
class DashDocSearchCommand (sublime_plugin .WindowCommand ):
73
94
def run (self ):
@@ -80,4 +101,4 @@ def on_cancel(self, name):
80
101
pass
81
102
82
103
def on_done (self , topic ):
83
- subprocess . call ([ "open" , "dash-plugin://query=" + quote ( topic )] )
104
+ open_dash ( topic , [], False )
0 commit comments