Skip to content

Commit

Permalink
[tosher#197] Headings folding fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tosher committed Feb 23, 2023
1 parent 81bf97c commit 5dceaa9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Changelog.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -686,3 +686,6 @@ Template example (<code>wiki_new_page.j2</code>):
== Mediawikier 3.6.13 ==
* Tag <code>math</code> attributes support
== Mediawikier 3.6.14 ==
* Headings folding fix
2 changes: 1 addition & 1 deletion messages.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"install": "messages/install.txt",
"3.6.13": "messages/latest_version.txt"
"3.6.14": "messages/latest_version.txt"
}
2 changes: 1 addition & 1 deletion messages/latest_version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Mediawiker 3.6.13
## Mediawiker 3.6.14

Please, check the release-notes in `Preferences / Package Settings / Mediawiker / Changelog`.
7 changes: 4 additions & 3 deletions mwcommands/mw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def set_attrs(self):
self.title = self.get_title()

def fold(self):
point_fold_b = self.region_text.b - len(self.open_tag) - 1 if self.region_text.b < self.view.size() else self.region_text.b
point_fold_b = self.region_text.b if self.region_text.b < self.view.size() else self.region_text.b
self.view.fold(sublime.Region(self.region.b, point_fold_b))

def unfold(self):
Expand All @@ -402,10 +402,11 @@ def get_title(self):

def get_next(self):
v = self.view
next_h_region = v.find(r'%s[^\%s]' % (self.open_tag, self.RESERVED_CHAR), self.region.b + 1)
find_regex = r'^{head_char}{{1,{head_char_cnt}}}[^\{head_char}]'.format(head_char=self.RESERVED_CHAR, head_char_cnt=self.level)
next_h_region = v.find(find_regex, self.region.b + 1)
# ST2 compat
if next_h_region:
next_h = next_h_region.b
next_h = next_h_region.a
else:
next_h = v.size()
return next_h if next_h > 0 else v.size()
Expand Down

0 comments on commit 5dceaa9

Please sign in to comment.