nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects

FR: `include_surrounding_whitespace` should adjust whitespace characters included based on mode

Open
#850 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Tree-sitter Query
Stars
2.8k
Forks
271
Avg merge
8d 8h
Merged PRs (30d)
1

Description

Is your feature request related to a problem? Please describe.
Enabling include_surrounding_whitespace often leads to technically correct, but somewhat unexpected behavior.

Given this text:

local obj = {
	text = "foobar", -- comment
	number = 123,
}

For instance, deleting the --comment via @comment.outer results in:

local obj = {
	text = "foobar", number = 123,
}

Which is technically correct – surrounding whitespace was included – but very unintuitive behavior.

Describe the solution you'd like
include_surrounding_whitespace should not include line breaks if the text object is characterwise.

Describe alternatives you've considered
Simply disabling include_surrounding_whitespace entirely (which is a waste, since it's in principle a nice feature)

Additional context
There are a few other issues like #575 which seem to be related to this problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Lua example with include_surrounding_whitespace enabled and inspect the text-object handling that determines which surrounding characters are included. Done means characterwise text objects exclude line breaks while preserving the intended surrounding whitespace behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, neovim
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.