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

insertText()'s location= argument -- is '0' a valid column number? #299

Open
MichaelChirico opened this issue Apr 13, 2024 · 2 comments
Open

Comments

@MichaelChirico
Copy link

MichaelChirico commented Apr 13, 2024

#' \code{location} should be a (list of) \code{\link{document_position}} or

I couldn't tell from ?insertText whether 0 is valid or not. Of course I could test this with RStudio available, but I don't have it available at the moment, so it would be good to have this written out. The source code of rstudioapi::insertText() also eventually refers to a function inside an environment only available inside RStudio, so I couldn't check that either:

get(name, envir = asNamespace("rstudio"), ...)

Context: We have a conflict in {lintr} of 0 being a valid column number for lint objects, apparently to support RStudio:

r-lib/lintr#2418 (comment)

But this conflicts with SARIF format (r-lib/lintr#2550), which requires column>0. I'd like to know if the fix is to block 0 as a column number everywhere, or if we should just block it when producing SARIF output.

To answer this I tried to refer to the {rstudioapi} documentation, but to no avail.

@kevinushey
Copy link
Contributor

It's allowed, but RStudio / rstudioapi used one-based indexing for document offsets, so inserting something at column 0 is the same as inserting it at column 1. (Same for row 0 versus row 1).

@MichaelChirico
Copy link
Author

OK, great. is it safe to say the same applies for our linting add-in? it will land the cursor on a column number, is there any difference for 0 vs 1 in that case (sorry, only now realizing focusing on insertText doesn't necessarily fully answer my underlying question)

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

No branches or pull requests

2 participants