Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting for allowing/preventing search to wrap around #897

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/search-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ module.exports = class SearchModel {

let currentMatch
const matches = this.matches.slice()
const wrap= this.vimState.getConfig("searchWrap")
if (relativeIndex >= 0) {
currentMatch = matches.find(range => range.start.isGreaterThan(fromPoint)) || this.firstMatch
currentMatch = matches.find(range => range.start.isGreaterThan(fromPoint)) || (wrap?this.firstMatch:this.lastMatch)
relativeIndex--
} else {
currentMatch = matches.reverse().find(range => range.start.isLessThan(fromPoint)) || this.lastMatch
currentMatch = matches.reverse().find(range => range.start.isLessThan(fromPoint)) || (wrap?this.lastMatch:this.firstMatch)
relativeIndex++
}

Expand Down
4 changes: 4 additions & 0 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ module.exports = new Settings("vim-mode-plus", {
description:
"[Can]: `I p`, `A p` to insert at start or end of `preset-occurrence` in paragraph(`p`).<br>`I` and `A` is operator which take target, you can combine it with any target like `I f`(`a-function`), `A z`(`a-fold`).<br>[Caution]: `I` and `A` behaves as operator as long as editor has `preset-occurrence`, even if there is no VISIBLE `preset-occurrence` in screen. You might want to `escape` to clear preset-occurrences on editor to make `I` and `A` behave normaly gain.<br>[Conflicts]: You cannot use normal `I` and `A` when `preset-occurrence` marker is exists.",
},
searchWrap:{
default: true,
description: "Allow search to wrap to top and bottom",
},
setCursorToStartOfChangeOnUndoRedo: true,
setCursorToStartOfChangeOnUndoRedoStrategy: {
default: "smart",
Expand Down