Skip to content

Commit

Permalink
refactor: tidy codes (ST>=4152)
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
  • Loading branch information
jfcherng committed Oct 31, 2023
1 parent 3d8b1f6 commit 2c98ebf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
4 changes: 0 additions & 4 deletions plugin/constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from __future__ import annotations

import sublime

PLUGIN_NAME = __package__.partition(".")[0]
SETTINGS_FILE_NAME = f"{PLUGIN_NAME}.sublime-settings"

ST_SUPPORT_EXPAND_TO_SCOPE = int(sublime.version()) >= 4132

URI_REGION_KEY = "OUIB_uri_regions"
VIEW_SETTING_TIMESTAMP_KEY = "OUIB_last_update_timestamp"
19 changes: 5 additions & 14 deletions plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import sublime

from .constants import ST_SUPPORT_EXPAND_TO_SCOPE, VIEW_SETTING_TIMESTAMP_KEY
from .constants import VIEW_SETTING_TIMESTAMP_KEY
from .types import RegionLike, T_AnyCallable


Expand Down Expand Up @@ -114,19 +114,10 @@ def view_find_all(
"""

def expand(region: sublime.Region) -> sublime.Region:
if ST_SUPPORT_EXPAND_TO_SCOPE:
return next(
filter(None, (view.expand_to_scope(region.a, selector) for selector in expand_selectors)),
region,
)

for selector in expand_selectors:
if not view.match_selector(region.a, selector):
continue
while view.match_selector(region.b, selector):
region.b += 1
break
return region
return next(
filter(None, (view.expand_to_scope(region.a, selector) for selector in expand_selectors)),
region,
)

if isinstance(expand_selectors, str):
expand_selectors = (expand_selectors,)
Expand Down

0 comments on commit 2c98ebf

Please sign in to comment.