Skip to content

Commit 22625ef

Browse files
authored
Merge pull request #54 from davidpeckham/issue53
Fixes issue #53
2 parents 5c9fafa + 9af383f commit 22625ef

File tree

5 files changed

+45
-39
lines changed

5 files changed

+45
-39
lines changed

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Contributors
1212
- skafian and purplelizard for suggesting source line numbers (Sublime Text 3 only)
1313
- timothyaaron for fixing a code folding bug and defaulting search to the word at cursor
1414
- poma for performance improvements, filtering in place, and adding commands for filtering in place and inverse filters
15+
- uglycoyote, reagle, and FichteFoll for their persistence and insight with issue #53

filter.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,38 @@ def prepare_output_line(self, line):
115115
return '%5d: %s' % (line_number, self.view.substr(line))
116116
else:
117117
return self.view.substr(line)
118+
119+
120+
class PromptFoldToLinesCommand(PromptFilterToLinesCommand):
121+
122+
def run(self, search_type='string', invert_search=False):
123+
self._run(search_type, "fold_to_lines", "Fold", invert_search)
124+
125+
126+
class FoldToLinesCommand(FilterToLinesCommand):
127+
128+
def show_filtered_lines(self, edit, lines):
129+
source_lines = self.view.lines(sublime.Region(0, self.view.size()))
130+
filtered_line_numbers = {
131+
self.view.rowcol(line.begin())[0] for line in lines
132+
}
133+
regions = []
134+
region = None
135+
for line in source_lines:
136+
matched = (
137+
self.view.rowcol(
138+
line.begin()
139+
)[0] in filtered_line_numbers) ^ self.invert_search
140+
if matched:
141+
if region:
142+
regions.append(region)
143+
region = None
144+
else:
145+
if region:
146+
region = region.cover(line)
147+
else:
148+
region = sublime.Region(line.begin(), line.end())
149+
if region:
150+
regions.append(region)
151+
if regions:
152+
self.view.fold(regions)

fold.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"3.0.0": "messages/3.0.0.md",
88
"3.1.0": "messages/3.1.0.md",
99
"3.1.2": "messages/3.1.2.md",
10-
"3.1.3": "messages/3.1.3.md"
10+
"3.1.3": "messages/3.1.3.md",
11+
"3.1.4": "messages/3.1.4.md"
1112
}

messages/3.1.4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#3.1.4 August 8, 2019
2+
3+
This release is for Sublime Text 3 users. I have separate versions of the plugin for Sublime Text 2 and 3, and the version for Sublime Text 2 remains unchanged for now.
4+
5+
##Changes
6+
7+
- Merged fold.py into filter.py as suggested by FichteFoll to resolve issue #53, which sometimes caused Filter Lines menu items to appear disabled in ST 3.

0 commit comments

Comments
 (0)