From d75689a5d94f8617d21a9446d5b485b9d6245edf Mon Sep 17 00:00:00 2001 From: Oliver Caldwell Date: Sat, 23 Sep 2023 14:54:41 +0100 Subject: [PATCH] Add a test for visually selecting top level forms --- .../text_object_selections_spec.lua | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/nvim-paredit/text_object_selections_spec.lua b/tests/nvim-paredit/text_object_selections_spec.lua index 83478fe..1fb4e5f 100644 --- a/tests/nvim-paredit/text_object_selections_spec.lua +++ b/tests/nvim-paredit/text_object_selections_spec.lua @@ -138,6 +138,34 @@ describe("form selections", function() end) end) +describe("top form selections", function() + vim.api.nvim_buf_set_option(0, "filetype", "clojure") + + before_each(function() + keybindings.setup_keybindings({ + keys = defaults.default_keys, + }) + end) + + it("should select the root form and not the siblings", function() + prepare_buffer({ + content = {"(+ 1 2)", "(foo (a", "a)) (/ 6 2)"}, + cursor = { 2, 6 }, + }) + feedkeys("vaF") + assert.are.same("(foo (a\na))", utils.get_selected_text()) + end) + + it("should select within the form", function() + prepare_buffer({ + content = {"(+ 1 2)", "(foo (a", "a)) (/ 6 2)"}, + cursor = { 2, 6 }, + }) + feedkeys("viF") + assert.are.same("foo (a\na)", utils.get_selected_text()) + end) +end) + describe("element deletions", function() vim.api.nvim_buf_set_option(0, "filetype", "clojure")