From 9ca2909c80ff95b1dd4a1d92b7144d7bbfce3ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Thu, 8 Apr 2021 15:58:20 +0900 Subject: [PATCH] Loop around the end on regex searches. --- .gitmodules | 3 +++ TODO.md | 3 +-- helix-syntax/nvim-treesitter | 1 + helix-term/src/commands.rs | 7 +++++-- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 160000 helix-syntax/nvim-treesitter diff --git a/.gitmodules b/.gitmodules index f4d6456c3..3cfb7b56e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -82,3 +82,6 @@ path = helix-syntax/languages/tree-sitter-toml url = https://github.com/ikatyang/tree-sitter-toml shallow = true +[submodule "helix-syntax/nvim-treesitter"] + path = helix-syntax/nvim-treesitter + url = https://github.com/nvim-treesitter/nvim-treesitter diff --git a/TODO.md b/TODO.md index 9561660e4..00855ac9d 100644 --- a/TODO.md +++ b/TODO.md @@ -27,7 +27,6 @@ - [ ] regex search / select next - [ ] = for auto indent line/selection -- [ ] yank on delete - [ ] :x for closing buffers - [x] jumplist (push selections on goto / select on the view) @@ -59,7 +58,7 @@ - [ ] macro recording - [x] tab completion for paths on the prompt - [ ] extend selection (treesitter select parent node) (replaces viw, vi(, va( etc ) -- [ ] bracket pairs +- [x] bracket pairs - [x] comment block (gcc) - [ ] completion signature popups/docs - [ ] selection align diff --git a/helix-syntax/nvim-treesitter b/helix-syntax/nvim-treesitter new file mode 160000 index 000000000..1f00ecdfa --- /dev/null +++ b/helix-syntax/nvim-treesitter @@ -0,0 +1 @@ +Subproject commit 1f00ecdfa36ef5e43a4feaf189e8c2c003118c00 diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 2e205fa60..0cbc3f9dc 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -612,8 +612,11 @@ fn _search(doc: &mut Document, view_id: ViewId, contents: &str, regex: &Regex) { let text = doc.text(); let start = doc.selection(view_id).cursor(); - // TODO: use find_at to find the next match after the cursor, loop around the end - if let Some(mat) = regex.find_at(contents, start) { + // use find_at to find the next match after the cursor, loop around the end + let mat = regex + .find_at(contents, start) + .or_else(|| regex.find(contents)); + if let Some(mat) = mat { let start = text.byte_to_char(mat.start()); let end = text.byte_to_char(mat.end()); let selection = Selection::single(start, end - 1);