Commit 83575703 authored by Nikita Sirgienko's avatar Nikita Sirgienko

[Sage] Fix bug with unworking loaded worksheets

BUG: 415893
FIXED-IN: 19.12.3
parent e313b343
......@@ -155,6 +155,15 @@ void SageSession::login()
m_process->pty()->write(initCmd);
//save the path to the worksheet as variable "__file__"
//this variable is usually set by the "os" package when running a script
//but when it is run in an interpreter (like sage server) it is not set
if (!m_worksheetPath.isEmpty())
{
const QString cmd = QLatin1String("__file__ = '%1'");
evaluateExpression(cmd.arg(m_worksheetPath), Cantor::Expression::DeleteOnFinish, true);
}
if(!SageSettings::self()->autorunScripts().isEmpty()){
QString autorunScripts = SageSettings::self()->autorunScripts().join(QLatin1String("\n"));
evaluateExpression(autorunScripts, SageExpression::DeleteOnFinish, true);
......@@ -459,11 +468,7 @@ void SageSession::setTypesettingEnabled(bool enable)
void SageSession::setWorksheetPath(const QString& path)
{
//save the path to the worksheet as variable "__file__"
//this variable is usually set by the "os" package when running a script
//but when it is run in an interpreter (like sage server) it is not set
const QString cmd = QLatin1String("__file__ = '%1'");
evaluateExpression(cmd.arg(path), Cantor::Expression::DeleteOnFinish, true);
m_worksheetPath = path;
}
Cantor::CompletionObject* SageSession::completionFor(const QString& command, int index)
......
......@@ -104,6 +104,7 @@ class SageSession : public Cantor::Session
QString m_outputCache;
VersionInfo m_sageVersion;
bool m_haveSentInitCmd;
QString m_worksheetPath;
};
#endif /* _SAGESESSION_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment