Skip to content

[wip] Added undo operation for xeus-cpp #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kr-2003
Copy link
Contributor

@kr-2003 kr-2003 commented May 1, 2025

Description

Undo last N operations.

Fixes #263

Screenshot 2025-05-01 at 12 53 29 PM

@kr-2003 kr-2003 marked this pull request as draft May 1, 2025 07:20
@kr-2003 kr-2003 changed the title Added undo operation for xeus-cpp [wip] Added undo operation for xeus-cpp May 1, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

{
try
{
n = std::stoi(code.substr(6));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "std::stoi" is directly included [misc-include-cleaner]

                        n = std::stoi(code.substr(6));
                                 ^

{
n = std::stoi(code.substr(6));
}
catch (const std::invalid_argument&)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "std::invalid_argument" is directly included [misc-include-cleaner]

src/xinterpreter.cpp:20:

- #ifndef EMSCRIPTEN
+ #include <stdexcept>
+ #ifndef EMSCRIPTEN

}
catch (const std::invalid_argument&)
{
throw std::runtime_error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]

                        throw std::runtime_error(
                                   ^

"Invalid format for %undo. Expected '%undo n' where n is an integer."
);
}
catch (const std::out_of_range&)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "std::out_of_range" is directly included [misc-include-cleaner]

                    catch (const std::out_of_range&)
                                      ^

throw std::runtime_error("Number out of range for %undo.");
}
}
compilation_result = Cpp::Undo(n) ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no member named 'Undo' in namespace 'Cpp' [clang-diagnostic-error]

                compilation_result = Cpp::Undo(n) ? true : false;
                                          ^

throw std::runtime_error("Number out of range for %undo.");
}
}
compilation_result = Cpp::Undo(n) ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: redundant boolean literal in ternary expression result [readability-simplify-boolean-expr]

Suggested change
compilation_result = Cpp::Undo(n) ? true : false;
compilation_result = Cpp::static_cast<bool>(Undo(n));

}
else
{
compilation_result = Cpp::Process(code.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "Cpp::Process" is directly included [misc-include-cleaner]

                compilation_result = Cpp::Process(code.c_str());
                                          ^

@anutosh491
Copy link
Collaborator

Maybe you can add a couple tests ?

@kr-2003
Copy link
Contributor Author

kr-2003 commented May 3, 2025

Maybe you can add a couple tests ?

Sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle undo for xeus-cpp/xeus-cpp-lite
2 participants