Vscode-r: Sending multi-line string removes lines starting with hash

Created on 6 May 2020  路  8Comments  路  Source: Ikuyadeu/vscode-R

Sending the following multi-line string to terminal removes # hello which is mistakenly treated as comment:

text <- "
# hello
this is new #hello
"

Instead the following is actually sent to terminal:

> text <- " 
  this is new #hello 
  "
bug

All 8 comments

I'm wondering if we could simply not remove comments from code to be sent to terminal and just send the original text since sometimes I need to take a look at history of my terminal commands with comments as my note and sections. Removing comments makes it hard to review the command history in terminal.

I'm wondering if we could simply not remove comments from code to be sent to terminal and just send the original text since sometimes I need to take a look at history of my terminal commands with comments as my note and sections.

I鈥檓 happy with this change being made.

Suppose

text <- "


# hello



this is new #hello
"

The blank lines and #-starting lines are all removed, which is undesired in multi-line strings.

This case still needs to be handled. I think this is why commented lines were removed in the first place.

function() {
    1
# }
    2
}

If the cursor is on the first line, all lines should be sent. That is, the closing brace on the comments line should not be matched with the opening brace.

Hmm, actually the # } case should already be handled by cleanLine, so it is probably safe just to not drop commented lines.

I tested with

function() {
    1
# }
    2
}

and it works well.

I'm wondering if cleanLine is still relevant for some cases?

Yes, cleanLine is still needed. Without it, the # } case will incorrectly match the commented brace.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dee-L picture Dee-L  路  5Comments

tdeenes picture tdeenes  路  5Comments

bdeshon picture bdeshon  路  3Comments

michaelHL picture michaelHL  路  3Comments

maxheld83 picture maxheld83  路  4Comments