benmarwick / wordcountaddin

Word counts and readability statistics in R markdown documents
Other
337 stars 33 forks source link

Error in if (text_is_selected) { : argument is of length zero #53

Closed kc-li closed 1 year ago

kc-li commented 1 year ago

While working on my long R markdown file which is meant to render to dox, I found that the word_count() Addin often not work and return errors:

Error in if (text_is_selected) { : argument is of length zero

However, if I restart the R session, this function can return the expected word count report again. I don't understand why this always happens.

benmarwick commented 1 year ago

Do you have a version of your Rmd, for example on a public GitHub repository, that I can access to investigate this error? I guess there is some characters in your text that is confusing the word count function.

kc-li commented 1 year ago

I figured out the reason! The addin can only be used under 'Source' mode, not the 'Visual' mode. It never reported the error message when I used this function under the 'Source' editing mode.