Nvim-R icon indicating copy to clipboard operation
Nvim-R copied to clipboard

\xx indentation proportional to function depth

Open jkroes opened this issue 5 years ago • 4 comments

Screen Shot 2020-03-17 at 8 41 26 AM

Expected behavior: With R_indent_commented=1, pressing \xx comments a line with '# ', then reindents it to align with indented code.

Actual behavior: With R_indent_commented=1, extra spacing is inserted between the '#' and the comment text. The amount of spacing is proportional to the nesting of the function

jkroes avatar Mar 17 '20 15:03 jkroes

Upon further investigation, the following happens: Within a function, add a new line. Remove indentation so that text on the news line starts at the beginning of the line. Then \xx indents the line and prepends '# ' (i.e., with a single space as expected). Press \xx twice, however, and the extra spacing is added. What seems to be happening is that the text and its indentation is being inserted after '# ', then the line is indented a second time. If you count it, the spacing after the '#' is always one space greater than the spacing beforehand.

jkroes avatar Mar 17 '20 16:03 jkroes

Could you, please:

  1. Paste a sample code that I could use (I can't copy the text from the image).
  2. Show two images: one with the actual indentation and the other with the indentation that would be the correct indentation.

jalvesaq avatar Mar 19 '20 13:03 jalvesaq

Sample code (formatted as expected):

fun1 <- function() {
  # comment1
  print('p1')
  fun2 <- function() {
    # comment2
    print('p2')
    fun3 <- function() {
      # comment3
      print('p3')
    }
  }
}

Result of pressing \xx twice on each comment line:

fun1 <- function() {
  #   comment1
  print('p1')
  fun2 <- function() {
    #     comment2
    print('p2')
    fun3 <- function() {
      #       comment3
      print('p3')
    }
  }
}

jkroes avatar Mar 21 '20 18:03 jkroes

I can't replicate the issue. Even if I do <LocalLeader>xx many times, the commented lines remain as in the first sample code.

jalvesaq avatar Mar 21 '20 18:03 jalvesaq