Skip to content

Commit 1bcd553

Browse files
committed
Removed Sublime Text 2 support
1 parent 7920406 commit 1bcd553

File tree

2 files changed

+8
-63
lines changed

2 files changed

+8
-63
lines changed

Filter Lines.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
import sublime_plugin
88

99

10-
st_version = 2
11-
if sublime.version() == '' or int(sublime.version()) > 3000:
12-
st_version = 3
13-
14-
15-
imap = itertools.imap if st_version == 2 else map
16-
17-
1810
def match_line(needle, haystack, search_type, case_sensitive, invert_search = False):
1911
if invert_search:
2012
return not search_line(needle, haystack, search_type, case_sensitive)
@@ -113,8 +105,6 @@ def filter_to_new_buffer(self, edit, needle, search_type, case_sensitive,
113105
results_view.set_name('Filter Results')
114106
results_view.set_scratch(True)
115107
results_view.settings().set('word_wrap', self.view.settings().get('word_wrap'))
116-
if st_version == 2:
117-
results_edit = results_view.begin_edit()
118108

119109
# get non-empty selections
120110
# regions = [s for s in self.view.sel() if not s.empty()]
@@ -126,7 +116,7 @@ def filter_to_new_buffer(self, edit, needle, search_type, case_sensitive,
126116

127117
if separator is None:
128118
lines = (self.view.split_by_newlines(r) for r in regions)
129-
lines = imap(self.view.substr,
119+
lines = map(self.view.substr,
130120
itertools.chain.from_iterable(lines))
131121
else:
132122
lines = itertools.chain.from_iterable(
@@ -141,24 +131,15 @@ def filter_to_new_buffer(self, edit, needle, search_type, case_sensitive,
141131
line += '\n'
142132
text += line
143133

144-
if st_version == 2:
145-
results_view.insert(results_edit, results_view.size(), text)
146-
else:
147-
results_view.run_command(
148-
'append', {'characters': text, 'force': True,
149-
'scroll_to_end': False})
134+
results_view.run_command(
135+
'append', {'characters': text, 'force': True,
136+
'scroll_to_end': False})
150137

151138
if results_view.size() > 0:
152139
results_view.set_syntax_file(self.view.settings().get('syntax'))
153140
else:
154141
message = 'Filtering lines for "%s" %s\n\n0 matches\n' % (needle, '(case-sensitive)' if case_sensitive else '(not case-sensitive)')
155-
if st_version == 2:
156-
results_view.insert(results_edit, results_view.size(), message)
157-
else:
158-
results_view.run_command('append', { 'characters': message, 'force': True, 'scroll_to_end': False })
159-
160-
if st_version == 2:
161-
results_view.end_edit(results_edit)
142+
results_view.run_command('append', { 'characters': message, 'force': True, 'scroll_to_end': False })
162143

163144
def filter_in_place(self, edit, needle, search_type, case_sensitive, invert_search):
164145
# get non-empty selections

README.md

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,14 @@
11
# Filter Lines
22

3-
A Sublime Text plugin that filters lines containing a string or matching a regular expression. Searches are case sensitive by default and use the Python regular expression syntax.
3+
Quickly find all lines matching a string or regular expression in Sublime Text 3.
44

5-
Works with Sublime Text 2 and 3.
6-
7-
* [How to install](#how-to-install)
8-
* [Available actions](#available-actions)
9-
* [Feedback](#feedback)
10-
* [Demo](#demo)
11-
12-
## How to install ##
13-
14-
### Package Control ###
15-
16-
Install Will Bond's [Package Control](https://sublime.wbond.net/installation), and then:
17-
18-
* In the Command Palette, choose `Package Control: Install Package`
19-
* Search for `Filter Lines` and install it
20-
21-
### Github ###
22-
23-
Go to your Sublime Text "Packages" directory (`Preferences` / `Browse Packages...`).
24-
25-
Then clone this GitHub repository:
26-
27-
$ git clone https://github.com/davidpeckham/FilterLines.git "Filter Lines"
28-
29-
## Available actions ##
30-
31-
* Edit > Line > Filter With Regex: <kbd>⌘+K</kbd> <kbd>⌘+R</kbd>
32-
* Edit > Line > Filter With String: <kbd>⌘+K</kbd> <kbd>⌘+S</kbd>
5+
* Edit > Line > Filter With Regex <kbd>⌘+K</kbd> <kbd>⌘+R</kbd>
6+
* Edit > Line > Filter With String <kbd>⌘+K</kbd> <kbd>⌘+S</kbd>
337
* Edit > Code Folding > Fold With Regex
348
* Edit > Code Folding > Fold With String
359

3610
On Windows and Linux, press the <kbd>ctrl</kbd> key instead of the <kbd>⌘</kbd> key.
3711

38-
## Preferences ##
39-
40-
* `case_sensitive_regex_search`: set this to true to make regex search case-sensitive (default is true)
41-
* `case_sensitive_string_search`: set this to true to make string search case-sensitive (default is false)
42-
* `use_new_buffer_for_filter_results`: set this to false to overwrite the current buffer
43-
* `preserve_search`: if true, remembers your latest search string or regex and uses it for your next search
44-
* `invert_search`: if true, find lines that do not match (useful when progressively eliminating noise in log files)
45-
* `custom_separator`: If true, show an input to specify a regex separator (instead of using line separator)
46-
4712
## Feedback ##
4813

4914
* https://github.com/davidpeckham/FilterLines/issues
@@ -52,7 +17,6 @@ On Windows and Linux, press the <kbd>ctrl</kbd> key instead of the <kbd>⌘</kbd
5217

5318
![Filter Lines Demo](https://dl.dropboxusercontent.com/u/44889921/filter_lines_demo.gif)
5419

55-
5620
## Thanks ##
5721

5822
Filter Lines is based on a Sublime Text 2 [plugin tutorial by Daniel Beck](http://superuser.com/questions/452189/how-can-i-filter-a-file-for-lines-containing-a-string-in-sublime-text-2). If you want to write a plugin, Daniel's tutorial is a good place to start.

0 commit comments

Comments
 (0)