Skip to content

Commit

Permalink
open all language files, and select option
Browse files Browse the repository at this point in the history
  • Loading branch information
absszero committed Oct 28, 2023
1 parent f93db2d commit b78ab91
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
20 changes: 16 additions & 4 deletions lib/router.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from .place import Place
from . import workspace
import os
import subprocess
import json
import sublime

from .place import Place
from . import workspace
from .setting import Setting
from .logging import log, exception

Expand All @@ -28,7 +31,7 @@ def update(self, filepath=None):
if not self.artisan or not self.dir:
return

is_routes_changed = workspace.is_changed(self.dir, filepath)
is_routes_changed = self.is_changed(filepath)
log('routes changed', is_routes_changed)
if not is_routes_changed:
return
Expand All @@ -48,7 +51,13 @@ def update(self, filepath=None):
log('args', args)

try:
output = subprocess.check_output(args, stderr=subprocess.STDOUT)
output = subprocess.check_output(
args,
cwd='/',
stderr=subprocess.STDOUT,
shell=os.name == 'nt'
)

except subprocess.CalledProcessError as e:
exception('check_output', e)
return
Expand All @@ -74,6 +83,9 @@ def update(self, filepath=None):
location=action
)

def is_changed(self, filepath=None):
return workspace.is_changed(self.dir, filepath)

def all(self):
self.update()
return routes
28 changes: 18 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,19 @@


class GotoLocation(sublime_plugin.EventListener):
def on_activated(self, view):
def on_load(self, view):
global place
filepath = view.file_name()
if (not place or not filepath):
place = None
return
if (basename(filepath) != basename(place.path)):
place = None
return
if (not isinstance(place.location, str)):
place = None
return

location = view.find(place.location, 0)
# fix .env not showing selected if no scrolling happened
view.set_viewport_position((0, 1))
view.sel().clear()
view.sel().add(location)
view.show(location)
place = None
spot_location(view, place.location)

def on_post_save_async(self, view):
Router().update(view.file_name())
Expand Down Expand Up @@ -185,5 +181,17 @@ def open_file_layouts(files=[]):
for (idx, file) in enumerate(files):
new_window.open_file(file)
new_window.set_view_index(new_window.active_view(), idx, 0)

return


def spot_location(view, location):
''' spot place location on view '''

if not location:
return
location = view.find(place.location, 0)
# fix .env not showing selected if no scrolling happened
view.set_viewport_position((0, 1))
view.sel().clear()
view.sel().add(location)
view.show(location)

0 comments on commit b78ab91

Please sign in to comment.