This repository was archived by the owner on Sep 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Addsearchprog #46
Open
eyalk11
wants to merge
2
commits into
ipod825:master
Choose a base branch
from
eyalk11:addsearchprog
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Addsearchprog #46
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2031,8 +2031,10 @@ def _NETRSearchUpdate(self): | |
|
||
ignore_case = False | ||
if pattern and pattern: | ||
if (Vim.options['smartcase'] and re.match( | ||
'[A-Z]', pattern)) or not Vim.options['ignorecase']: | ||
if (Vim.options['smartcase'] and | ||
re.match("(?=.*[a-z])(?=.*[A-Z])",pattern)) and not Vim.options['ignorecase']: | ||
# if (Vim.options['smartcase'] and re.match( | ||
# '[A-Z]', pattern)) or not Vim.options['ignorecase']: | ||
pattern = re.compile('.*' + pattern) | ||
else: | ||
pattern = re.compile('.*' + pattern, re.IGNORECASE) | ||
|
@@ -2076,6 +2078,26 @@ def _NETRSearchStop(self, accept): | |
# clear command line | ||
Vim.command('echo') | ||
|
||
def _NETRSearchGTNext(self,forward): | ||
if forward: | ||
accept_line_nr = [n.name for n in self._cur_search_buf.nodes | ||
].index(Vim.current.line) + 1 | ||
|
||
self._NETRSearchStop(True) | ||
if forward: | ||
nod=self.cur_buf.nodes[accept_line_nr-1] | ||
self.cur_buf._redraw() | ||
self.cur_buf.set_clineno_by_node(nod) | ||
# self.cur_buf.update_nodes_and_redraw(force_redraw=True) | ||
if nod.is_DIR: | ||
self.NETRBufOpen() | ||
self.NETRSearch() | ||
else: | ||
self.NETRParentDir() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this is a very niche need. Why would you want to go to parent directory when you search? Search and goto the search target sounds like a plausible need, but search and goto parent sounds like two unrelated things. |
||
self.NETRSearch() | ||
|
||
Vim.command('echo') | ||
|
||
def _NETRSearchMove(self, binding): | ||
if binding[0] == '<': | ||
binding = f'\{binding}>' | ||
|
@@ -2084,13 +2106,16 @@ def _NETRSearchMove(self, binding): | |
def _NETRSearchMap(self): | ||
stop_template = 'cnoremap <buffer> {} <cmd>python3 ranger._NETRSearchStop({})<cr><cr>' | ||
move_template = 'cnoremap <buffer><nowait> {} <cmd>python3 ranger._NETRSearchMove("{}")<cr>' | ||
gt_template = 'cnoremap <buffer><nowait> {} <cmd>python3 ranger._NETRSearchGTNext({})<cr>' | ||
Vim.command(stop_template.format('<cr>', True)) | ||
Vim.command(stop_template.format('<esc>', False)) | ||
Vim.command(stop_template.format('<c-c>', False)) | ||
Vim.command(move_template.format('<c-j>', '<down')) | ||
Vim.command(move_template.format('<c-k>', '<up')) | ||
Vim.command(move_template.format('<down>', '<down')) | ||
Vim.command(move_template.format('<up>', '<up')) | ||
Vim.command(gt_template.format('<c-/>',True)) | ||
Vim.command(gt_template.format('<M-/>',False)) | ||
|
||
def NETRSearch(self): | ||
self._cur_search_buf = self.cur_buf | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use fstring to be consistent with other part of the codebase.