Skip to content

Commit

Permalink
Merge branch 'vini175pa-master'
Browse files Browse the repository at this point in the history
* vini175pa-master:
  Bump version to 0.2.2
  Prevent infinite reruns when no selection is made
  Don't stop recursion if no item is selected
  Remove unused arguments for "import_js_replace" command
  Namespace "replace" command > "import_js_replace"
  Fixed the dropdown insertion + Cancel dropdown insertion added
  • Loading branch information
trotzig committed Jan 6, 2016
2 parents ebd3b16 + cdc3c09 commit d3945b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions import-js.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ def no_executable_error(executable):
'from the command line.'
)

class ImportJsReplaceCommand(sublime_plugin.TextCommand):
def run(self, edit, characters):
self.view.replace(edit, sublime.Region(0, self.view.size()), characters)

class ImportJsCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
entire_file_region = sublime.Region(0, self.view.size())
current_file_contents = self.view.substr(entire_file_region)
current_file_contents = self.view.substr(sublime.Region(0, self.view.size()))

environment = { 'LC_ALL': 'en_US.UTF-8', 'LC_CTYPE': 'UTF-8', 'LANG': 'en_US.UTF-8' }
project_root = self.view.window().extract_variables()['folder']
Expand Down Expand Up @@ -73,16 +75,19 @@ def run(self, edit, **args):
if(meta.get('messages')):
sublime.status_message(meta.get('messages'))
if(meta.get('ask_for_selections')):
rerun = lambda selections: self.rerun(edit, args, selections)
self.ask_for_selections(meta.get('ask_for_selections'), rerun)
def handle_selections_done(selections):
if (len(selections)):
self.rerun(edit, args, selections)
self.ask_for_selections(meta.get('ask_for_selections'),
handle_selections_done)
return

stdout = result[0].decode()
if(args.get('goto')):
if(len(stdout.rstrip()) > 0):
self.view.window().open_file(self.project_path() + '/' + stdout.rstrip())
else:
self.view.replace(edit, entire_file_region, stdout)
self.view.run_command("import_js_replace", {"characters": stdout})

def rerun(self, edit, args, selections):
args['selections'] = selections
Expand All @@ -103,7 +108,8 @@ def ask_recurse(selection):
return

def on_done(i):
selected.append(selection.get('word') + ':' + str(i))
if(i > -1):
selected.append(selection.get('word') + ':' + str(i))
ask_recurse(next(selections_iter, None))

self.view.show_popup_menu(
Expand Down
2 changes: 1 addition & 1 deletion lib/import_js/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Defines the gem version.
module ImportJS
VERSION = '0.2.1'
VERSION = '0.2.2'
end

0 comments on commit d3945b0

Please sign in to comment.