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
"
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.