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

Change Textobj: Consider extending {notifyNotFound=false} to indentation object's warning "Current line is not indented" #97

Closed
2 tasks done
tuurep opened this issue Jul 27, 2024 · 6 comments

Comments

@tuurep
Copy link

tuurep commented Jul 27, 2024

Change requested

I'd prefer to have all warnings turned off when there's nothing to be done, so would feel consistent if for example dii on an unindented line wouldn't give a warning message either when notifyNotFound=false

Looks like there's also a warning "No indented line found." (code) associated with indentation textobj, but I haven't found in what situation that emits. But most likely my request concerns that too.

Relevant PR where notifyNotFound was added: #85

Sample Text

require("various-textobjs").setup({notifyNotFound = false})
Unindented line hello foo bar
^

Press dii

Gives warning "Current line is not indented."

But could it be quiet?

Checklist

@tuurep
Copy link
Author

tuurep commented Jul 27, 2024

It could be opinionated though because this isn't the same kind of "not found within n lines" message as the one disabled by notifyNotFound=false.

Alternative idea: some kinda quiet option, as a sort of second level of quietness.

@chrisgrieser
Copy link
Owner

chrisgrieser commented Jul 27, 2024

Ah yes, those two were simply overlooked. Can you make a PR adding notifyNotFound as conditional to those two notifications?

(I'm not at home for a bit but I have Github mobile access, where accepting PRs is ready though)

@tuurep
Copy link
Author

tuurep commented Jul 27, 2024

Thanks, yeah I can make one and good to know my request made perfect sense :)

@tuurep
Copy link
Author

tuurep commented Jul 27, 2024

Although are there more cases related to this? Examples:

u.notify("No diagnostic found.", "warn")

u.notify("No node found.", "warn")

u.notify("Not on a triple quoted string.", "warn")

Edit:

Yeah the reason it is the way it is is because the only place where notifyNotFound is checked against is here:

---notification when no textobj could be found
---@param lookForwL integer number of lines the plugin tried to look forward
function M.notFoundMsg(lookForwL)
if not require("various-textobjs.config").config.notifyNotFound then return end
local msg = "Textobject not found within the next " .. tostring(lookForwL) .. " lines."
if lookForwL == 1 then msg = msg:gsub("s%.$", ".") end -- remove plural s
M.notify(msg, "warn")
end

So I'm wondering whether we want to wrap other warnings in a similar util function and check it there too, or if there's a need to have more granularity (a second quietflag)?

@chrisgrieser
Copy link
Owner

fixed all cases

@tuurep
Copy link
Author

tuurep commented Jul 27, 2024

Astonishing. Thank you very much 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants