Skip to content

Commit c3d9dc3

Browse files
fix #23, Fixed auto-complete tooltip that was showing up also in on_selection_modified event, Updated flow-bin to 0.64.0
1 parent 8a19fd7 commit c3d9dc3

File tree

9 files changed

+158
-1586
lines changed

9 files changed

+158
-1586
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
node_binaries/
33
node_modules/
44
**/__pycache__
5-
/helper/bookmarks/bookmarks.json
5+
/helper/bookmarks/bookmarks.json
6+
package-lock.json

_generated_2018_01_25_at_15_56_26.py renamed to _generated_2018_01_26_at_21_58_40.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from os import environ
66
from subprocess import Popen, PIPE
77

8-
PLUGIN_VERSION = "0.13.16"
8+
PLUGIN_VERSION = "0.13.17"
99

1010
PACKAGE_PATH = os.path.abspath(os.path.dirname(__file__))
1111
PACKAGE_NAME = os.path.basename(PACKAGE_PATH)
@@ -1336,10 +1336,16 @@ def init(self):
13361336

13371337
node_modules_path = os.path.join(PACKAGE_PATH, "node_modules")
13381338
npm = NPM()
1339+
1340+
if os.path.exists(node_modules_path) and not os.path.exists(os.path.join(node_modules_path, ".bin")):
1341+
if sublime.platform() == "windows":
1342+
os.system("taskkill /f /im flow.exe")
1343+
shutil.rmtree(node_modules_path)
1344+
13391345
if not os.path.exists(node_modules_path):
13401346
animation_npm_installer = AnimationLoader(["[= ]", "[ = ]", "[ = ]", "[ = ]", "[ =]", "[ = ]", "[ = ]", "[ = ]"], 0.067, "JavaScript Enhancements - installing npm dependencies ")
13411347
interval_animation = RepeatedTimer(animation_npm_installer.sec, animation_npm_installer.animate)
1342-
# sublime.active_window().status_message("JavaScript Enhancements - installing npm dependencies...")
1348+
13431349
result = npm.install_all()
13441350
if result[0]:
13451351
animation_npm_installer.on_complete()
@@ -1353,10 +1359,6 @@ def init(self):
13531359
shutil.rmtree(node_modules_path)
13541360
sublime.error_message("Error during installation: can't install npm dependencies for JavaScript Enhancements plugin.\n\nThe error COULD be caused by the npm permission access (EACCES error), so in this case you need to repair/install node.js and npm in a way that doesn't require \"sudo\" command.\n\nFor example you could use a Node Version Manager, such as \"nvm\" or \"nodenv\".\n\nTry to run \"npm install\" inside the package of this plugin to see what you get.")
13551361
return
1356-
# else:
1357-
# result = npm.update_all()
1358-
# if not result[0]:
1359-
# sublime.active_window().status_message("Error: JavaScript Enhancements - cannot update npm dependencies.")
13601362

13611363
sublime.set_timeout_async(lambda: overwrite_default_javascript_snippet())
13621364

@@ -3825,7 +3827,6 @@ def on_query_completions_async(self, view, prefix, locations):
38253827
self.searching = False
38263828
return
38273829

3828-
38293830
node = NodeJS(check_local=True)
38303831

38313832
result = node.execute_check_output(
@@ -3851,6 +3852,8 @@ def on_query_completions_async(self, view, prefix, locations):
38513852
if self.modified == True:
38523853
self.searching = False
38533854
return
3855+
3856+
38543857

38553858
result = result[1]
38563859
self.completions = list()
@@ -3923,6 +3926,11 @@ def on_text_command(self, view, command_name, args):
39233926
'hide_auto_complete'
39243927
)
39253928

3929+
elif command_name == "drag_select" :
3930+
if view.sel()[0].begin() < view.word(view.sel()[0].begin()).end():
3931+
self.modified = True
3932+
self.searching = False
3933+
39263934
def on_selection_modified_async(self, view) :
39273935

39283936
selections = view.sel()
@@ -3936,13 +3944,13 @@ def on_selection_modified_async(self, view) :
39363944
):
39373945
return
39383946

3939-
scope1 = view.scope_name(selections[0].begin()-1).strip()
3940-
scope2 = view.scope_name(selections[0].begin()-2).strip()
3947+
scope1 = view.scope_name(sel.begin()-1).strip()
3948+
scope2 = view.scope_name(sel.begin()-2).strip()
39413949

3942-
if (scope1.endswith(" punctuation.accessor.js") or scope1.endswith(" keyword.operator.accessor.js")) and not (scope2.endswith(" punctuation.accessor.js") or scope2.endswith(" keyword.operator.accessor.js")) and view.substr(selections[0].begin()-2).strip() :
3943-
3950+
if (scope1.endswith(" punctuation.accessor.js") or scope1.endswith(" keyword.operator.accessor.js")) and not (scope2.endswith(" punctuation.accessor.js") or scope2.endswith(" keyword.operator.accessor.js")) and view.substr(sel.begin()-2).strip() :
3951+
39443952
locations = list()
3945-
locations.append(selections[0].begin())
3953+
locations.append(sel.begin())
39463954

39473955
if not self.searching:
39483956
self.searching = True
@@ -6029,12 +6037,16 @@ def fixPath():
60296037

60306038

60316039
def plugin_unloaded():
6032-
# When we unload, reset PATH to original value. Otherwise, reloads of this plugin will cause
6033-
# the PATH to be duplicated.
6034-
environ['PATH'] = fixPathOriginalEnv['PATH']
6040+
if platform.system() == "Darwin" or platform.system() == "Linux":
6041+
# When we unload, reset PATH to original value. Otherwise, reloads of this plugin will cause
6042+
# the PATH to be duplicated.
6043+
environ['PATH'] = fixPathOriginalEnv['PATH']
6044+
6045+
global fixPathSettings
6046+
fixPathSettings.clear_on_change('fixpath-reload')
60356047

6036-
global fixPathSettings
6037-
fixPathSettings.clear_on_change('fixpath-reload')
6048+
node = NodeJS(check_local=True)
6049+
sublime.set_timeout_async(lambda: node.execute("flow", ["stop"], is_from_bin=True, chdir=os.path.join(PACKAGE_PATH, "flow")))
60386050

60396051
##
60406052
## end - Fix Mac Path plugin code

changelog/0.13.17.txt

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
v0.13.17
2+
3+
## Fixes
4+
5+
- Fixed node_modules folder issue #23 during plugin upgrade on Windows
6+
- Fixed auto-complete tooltip that was showing up also in on_selection_modified event
7+
8+
## Improvements
9+
10+
- Updated flow-bin to 0.64.0
11+
12+
13+
=================================================================
14+
** THIS PLUGIN IS IN BETA! Thanks for your support in advance! **
15+
=================================================================
16+
17+
If you like it, remember to star it ⭐ on GitHub: https://github.com/pichillilorenzo/JavaScriptEnhancements
18+
19+
** USAGE **
20+
===========
21+
22+
See how it works on the Wiki: 👉👉 https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki 👈👈
23+
24+
25+
** WHAT IS THIS? **
26+
===================
27+
28+
This plugin uses Flow (javascript static type checker from Facebook) under the hood.
29+
30+
It offers better javascript autocomplete and a lot of features about creating,
31+
developing and managing javascript projects, such as:
32+
33+
- Cordova projects (run cordova emulate, build, compile, serve, etc. directly from Sublime Text!)
34+
- Ionic v1 and v2 projects (same as Cordova projects!)
35+
- Angular v1 and v2 projects
36+
- React projects (only about the creation at this moment)
37+
- React Native projects (only about the creation at this moment. I will add also NativeScript support)
38+
- Express projects (only about the creation at this moment)
39+
- Yeoman generators
40+
- Local bookmarks project
41+
- JavaScript real-time errors
42+
- etc.
43+
44+
You could use it also in existing projects (see the Wiki - https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki/Using-it-with-an-existing-project)!
45+
46+
It turns Sublime Text into a JavaScript IDE like!
47+
48+
This project is based on my other Sublime Text plugin JavaScript Completions (https://github.com/pichillilorenzo/JavaScript-Completions)
49+
50+
** NOTE **
51+
If you want use this plugin, you may want uninstall/disable the JavaScript Completions plugin, if installed.
52+
53+
** OS SUPPORTED NOW **
54+
======================
55+
56+
👉 Linux (64-bit)
57+
👉 Mac OS X
58+
👉 Windows (64-bit): released without the use of TerminalView plugin. For each feature (like also creating a project) will be used the cmd.exe shell (so during the creation of a project don't close it until it finishes!). Unfortunately the TerminalView plugin supports only Linux-based OS 😞. Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
59+
60+
❗❗ Dependencies ❗❗
61+
=======================
62+
63+
In order to work properly, this plugin has some dependencies:
64+
65+
👉 Sublime Text 3 (build 3124 or newer)
66+
👉 Node.js and npm (https://nodejs.org or nvm (https://github.com/creationix/nvm))
67+
👉 TerminalView (only for Linux and Mac OS X) sublime text plugin (https://github.com/Wramberg/TerminalView)
68+
69+
Not required, but useful for typescript files (Flow wont work on this type of files):
70+
71+
👉 TypeScript sublime text plugin (https://github.com/Microsoft/TypeScript-Sublime-Plugin)
72+
73+
** Flow Requirements **
74+
=======================
75+
76+
It use [Flow](https://github.com/facebook/flow) for type checking and auto-completions.
77+
78+
👉 Mac OS X
79+
👉 Linux (64-bit)
80+
👉 Windows (64-bit)
81+
82+
Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com
83+
84+
** Donation **
85+
==============
86+
87+
If this project help you reduce time to develop and also you like it, please support it with a donation 😄👍. Thanks!
88+
89+
Open Collective: https://opencollective.com/javascriptenhancements/donate
90+
PayPal: https://www.paypal.me/LorenzoPichilli
91+
92+
Thanks anyway for your support! 😄😄
93+
94+
MIT License

helper/javascript_completions/on_query_completions_event_listener.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def on_query_completions_async(self, view, prefix, locations):
127127
self.searching = False
128128
return
129129

130-
131130
node = NodeJS(check_local=True)
132131

133132
result = node.execute_check_output(
@@ -153,6 +152,8 @@ def on_query_completions_async(self, view, prefix, locations):
153152
if self.modified == True:
154153
self.searching = False
155154
return
155+
156+
156157

157158
result = result[1]
158159
self.completions = list()
@@ -225,6 +226,11 @@ def on_text_command(self, view, command_name, args):
225226
'hide_auto_complete'
226227
)
227228

229+
elif command_name == "drag_select" :
230+
if view.sel()[0].begin() < view.word(view.sel()[0].begin()).end():
231+
self.modified = True
232+
self.searching = False
233+
228234
def on_selection_modified_async(self, view) :
229235

230236
selections = view.sel()
@@ -238,13 +244,13 @@ def on_selection_modified_async(self, view) :
238244
):
239245
return
240246

241-
scope1 = view.scope_name(selections[0].begin()-1).strip()
242-
scope2 = view.scope_name(selections[0].begin()-2).strip()
247+
scope1 = view.scope_name(sel.begin()-1).strip()
248+
scope2 = view.scope_name(sel.begin()-2).strip()
243249

244-
if (scope1.endswith(" punctuation.accessor.js") or scope1.endswith(" keyword.operator.accessor.js")) and not (scope2.endswith(" punctuation.accessor.js") or scope2.endswith(" keyword.operator.accessor.js")) and view.substr(selections[0].begin()-2).strip() :
245-
250+
if (scope1.endswith(" punctuation.accessor.js") or scope1.endswith(" keyword.operator.accessor.js")) and not (scope2.endswith(" punctuation.accessor.js") or scope2.endswith(" keyword.operator.accessor.js")) and view.substr(sel.begin()-2).strip() :
251+
246252
locations = list()
247-
locations.append(selections[0].begin())
253+
locations.append(sel.begin())
248254

249255
if not self.searching:
250256
self.searching = True

make/_init.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from os import environ
66
from subprocess import Popen, PIPE
77

8-
PLUGIN_VERSION = "0.13.16"
8+
PLUGIN_VERSION = "0.13.17"
99

1010
PACKAGE_PATH = os.path.abspath(os.path.dirname(__file__))
1111
PACKAGE_NAME = os.path.basename(PACKAGE_PATH)
@@ -97,10 +97,16 @@ def init(self):
9797

9898
node_modules_path = os.path.join(PACKAGE_PATH, "node_modules")
9999
npm = NPM()
100+
101+
if os.path.exists(node_modules_path) and not os.path.exists(os.path.join(node_modules_path, ".bin")):
102+
if sublime.platform() == "windows":
103+
os.system("taskkill /f /im flow.exe")
104+
shutil.rmtree(node_modules_path)
105+
100106
if not os.path.exists(node_modules_path):
101107
animation_npm_installer = AnimationLoader(["[= ]", "[ = ]", "[ = ]", "[ = ]", "[ =]", "[ = ]", "[ = ]", "[ = ]"], 0.067, "JavaScript Enhancements - installing npm dependencies ")
102108
interval_animation = RepeatedTimer(animation_npm_installer.sec, animation_npm_installer.animate)
103-
# sublime.active_window().status_message("JavaScript Enhancements - installing npm dependencies...")
109+
104110
result = npm.install_all()
105111
if result[0]:
106112
animation_npm_installer.on_complete()
@@ -114,10 +120,6 @@ def init(self):
114120
shutil.rmtree(node_modules_path)
115121
sublime.error_message("Error during installation: can't install npm dependencies for JavaScript Enhancements plugin.\n\nThe error COULD be caused by the npm permission access (EACCES error), so in this case you need to repair/install node.js and npm in a way that doesn't require \"sudo\" command.\n\nFor example you could use a Node Version Manager, such as \"nvm\" or \"nodenv\".\n\nTry to run \"npm install\" inside the package of this plugin to see what you get.")
116122
return
117-
# else:
118-
# result = npm.update_all()
119-
# if not result[0]:
120-
# sublime.active_window().status_message("Error: JavaScript Enhancements - cannot update npm dependencies.")
121123

122124
sublime.set_timeout_async(lambda: overwrite_default_javascript_snippet())
123125

@@ -230,12 +232,16 @@ def fixPath():
230232

231233

232234
def plugin_unloaded():
233-
# When we unload, reset PATH to original value. Otherwise, reloads of this plugin will cause
234-
# the PATH to be duplicated.
235-
environ['PATH'] = fixPathOriginalEnv['PATH']
235+
if platform.system() == "Darwin" or platform.system() == "Linux":
236+
# When we unload, reset PATH to original value. Otherwise, reloads of this plugin will cause
237+
# the PATH to be duplicated.
238+
environ['PATH'] = fixPathOriginalEnv['PATH']
236239

237-
global fixPathSettings
238-
fixPathSettings.clear_on_change('fixpath-reload')
240+
global fixPathSettings
241+
fixPathSettings.clear_on_change('fixpath-reload')
242+
243+
node = NodeJS(check_local=True)
244+
sublime.set_timeout_async(lambda: node.execute("flow", ["stop"], is_from_bin=True, chdir=os.path.join(PACKAGE_PATH, "flow")))
239245

240246
##
241247
## end - Fix Mac Path plugin code

messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"0.13.13": "changelog/0.13.13.txt",
1717
"0.13.14": "changelog/0.13.14.txt",
1818
"0.13.15": "changelog/0.13.15.txt",
19-
"0.13.16": "changelog/0.13.16.txt"
19+
"0.13.16": "changelog/0.13.16.txt",
20+
"0.13.17": "changelog/0.13.17.txt"
2021
}

0 commit comments

Comments
 (0)