Skip to content

Commit

Permalink
correctly handle multiline console input in presentation log
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Mar 29, 2013
1 parent ff7c87a commit 6c89fad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cpp/r/include/r/session/RSessionUtils.hpp
Expand Up @@ -30,6 +30,8 @@ namespace utils {
// check for R 3.0 // check for R 3.0
bool isR3(); bool isR3();


bool isDefaultPrompt(const std::string& prompt);

// user home path // user home path
const core::FilePath& userHomePath(); const core::FilePath& userHomePath();


Expand All @@ -39,6 +41,7 @@ core::FilePath tempFile(const std::string& prefix,
const std::string& extension); const std::string& extension);


core::FilePath tempDir(); core::FilePath tempDir();



// suppress output in scope // suppress output in scope
class SuppressOutputInScope class SuppressOutputInScope
Expand Down
5 changes: 5 additions & 0 deletions src/cpp/r/session/RSession.cpp
Expand Up @@ -1594,6 +1594,11 @@ bool isR3()
return s_isR3; return s_isR3;
} }


bool isDefaultPrompt(const std::string& prompt)
{
return prompt == r::options::getOption<std::string>("prompt");
}

const FilePath& userHomePath() const FilePath& userHomePath()
{ {
return s_options.userHomePath; return s_options.userHomePath;
Expand Down
5 changes: 5 additions & 0 deletions src/cpp/session/modules/presentation/PresentationLog.cpp
Expand Up @@ -30,6 +30,7 @@


#include <r/RSexp.hpp> #include <r/RSexp.hpp>
#include <r/RExec.hpp> #include <r/RExec.hpp>
#include <r/session/RSessionUtils.hpp>


#include "PresentationState.hpp" #include "PresentationState.hpp"


Expand Down Expand Up @@ -109,6 +110,10 @@ void Log::onConsolePrompt(const std::string& prompt)
if (!presentation::state::isActive()) if (!presentation::state::isActive())
return; return;


// ignore if this isn't the default prompt
if (!r::session::utils::isDefaultPrompt(prompt))
return;

if (!consoleInputBuffer_.empty()) if (!consoleInputBuffer_.empty())
{ {
std::string input = boost::algorithm::trim_copy( std::string input = boost::algorithm::trim_copy(
Expand Down

0 comments on commit 6c89fad

Please sign in to comment.