Skip to content

Commit

Permalink
style: make flake8 happy
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed Oct 3, 2020
1 parent 704da7c commit d72812c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ace_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sublime
import sublime_plugin

from typing import Any, Callable, Dict, List, Optional, Union, cast
from typing import Any, Dict, List, Union, cast

from .libs import width_converter
from .libs.xpinyin import Pinyin
Expand All @@ -13,6 +13,8 @@
SETTINGS_FILENAME = "AceJump.sublime-settings"
SYTNAX_FILENAME = "Packages/{}/AceJump.sublime-syntax".format(PACKAGE_NAME)

CHINESE_REGEX_OBJ = re.compile("[\u4E00-\u9FD5]+", re.U)

PHANTOM_TEMPLATE = """
<body class="ace-jump-phantom">
<style>{css}</style>
Expand All @@ -35,8 +37,6 @@
xpy = Pinyin()
last_index = 0
hints = [] # type: List[sublime.Region]
search_regex = r""
chinese_regex_obj = re.compile("[\u4E00-\u9FD5]+", re.U)
phantom_sets = {} # type: Dict[int, sublime.PhantomSet]

next_search = False # type: Union[int, bool]
Expand Down Expand Up @@ -495,7 +495,7 @@ def find(self, regex: str, region_type: str, max_labels: int, case_sensitive: bo
# 測試用句子:如果方法中若传入变量,那么直接加前缀是不可以了。而是要将变量转为utf-8编码
# find matched Chinese chars from the target region
matched_chinese_chars = set()
for match in chinese_regex_obj.finditer(content):
for match in CHINESE_REGEX_OBJ.finditer(content):
chinese_string = content[slice(*match.span())]

for idx, char_pinyin in enumerate(xpy.get_pinyin(chinese_string, "-").split("-")):
Expand Down Expand Up @@ -532,7 +532,7 @@ def add_labels(self, edit: sublime.Edit, regions: List[sublime.Region], labels:
if self.hinting_mode == HINTING_MODE_REPLACE_CHAR:
# if the target char is Chinese,
# use full-width label to prevent from content position shifting
if chinese_regex_obj.match(self.view.substr(region)):
if CHINESE_REGEX_OBJ.match(self.view.substr(region)):
label = width_converter.h2f(label)

self.view.replace(edit, region, label)
Expand Down

0 comments on commit d72812c

Please sign in to comment.