Skip to content

Commit

Permalink
refactor: tidy codes
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
  • Loading branch information
jfcherng committed May 25, 2024
1 parent 46c071c commit 6004012
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions plugin/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

POINT = int
TUPLE_REGION = Tuple[POINT, POINT]
INDENT_LEVEL = int

if sys.version_info >= (3, 11):
from enum import StrEnum
Expand Down
6 changes: 3 additions & 3 deletions plugin/view_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import sublime

from .data_types import IndentInfo, LevelStyle
from .data_types import INDENT_LEVEL, IndentInfo, LevelStyle
from .helpers import get_regions_key
from .indent_renderer import AbstractIndentRenderer, find_indent_renderer
from .settings import get_level_colors, get_level_style
Expand All @@ -17,7 +17,7 @@ def calcualte_level_regions(
*,
indent_info: IndentInfo | None = None,
regions: Sequence[sublime.Region] | None = None,
) -> defaultdict[int, list[sublime.Region]]:
) -> defaultdict[INDENT_LEVEL, list[sublime.Region]]:
"""
Calculates regions of indents for each level.
Expand All @@ -36,7 +36,7 @@ def calcualte_level_regions(
regions = (sublime.Region(0, view.size()),)

whole_content = view.substr(sublime.Region(0, view.size()))
level_regions: defaultdict[int, list[sublime.Region]] = defaultdict(list)
level_regions: defaultdict[INDENT_LEVEL, list[sublime.Region]] = defaultdict(list)
for region in regions:
for m in indent_info.indent_pattern_compiled.finditer(whole_content, region.begin(), region.end()):
for level, level_pt in enumerate(range(m.start(), m.end(), indent_info.indent_length)):
Expand Down

0 comments on commit 6004012

Please sign in to comment.