Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions include/bolt/editor/command_history.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@

#ifndef COMMAND_HISTORY_HPP
#define COMMAND_HISTORY_HPP
#ifndef BOLT_EDITOR_COMMAND_HISTORY_HPP_
#define BOLT_EDITOR_COMMAND_HISTORY_HPP_

#include <deque>
#include <string>

#include "bolt/core/thread_safety.hpp"

namespace bolt {

class CommandHistory {
private:
private:
ThreadSafe<std::deque<std::string>> history_;
ThreadSafe<size_t> maxSize_{100};
ThreadSafe<size_t> currentIndex_{0};

public:
public:
static CommandHistory& getInstance() {
static CommandHistory instance;
return instance;
Expand All @@ -34,32 +35,38 @@ class CommandHistory {
}

std::string getPreviousCommand() {
return history_.read([&](const auto& hist) {
if (hist.empty()) return std::string();

size_t idx = currentIndex_.write([&](auto& current) {
if (current > 0) current--;
return current;
});

return idx < hist.size() ? hist[idx] : std::string();
return stepHistory([](size_t& current, size_t) {
if (current > 0)
current--;
});
}

std::string getNextCommand() {
return stepHistory([](size_t& current, size_t historySize) {
if (current < historySize)
current++;
});
}

private:
// Moves currentIndex_ with step(index, history size) and returns the command at the new index, or an empty
// string if there is none. Takes the history_ read lock first, then the currentIndex_ write lock.
template <typename Step>
std::string stepHistory(Step&& step) {
return history_.read([&](const auto& hist) {
if (hist.empty()) return std::string();

if (hist.empty())
return std::string();

size_t idx = currentIndex_.write([&](auto& current) {
if (current < hist.size()) current++;
step(current, hist.size());
return current;
});

return idx < hist.size() ? hist[idx] : std::string();
});
}
};

} // namespace bolt
} // namespace bolt

#endif
#endif // BOLT_EDITOR_COMMAND_HISTORY_HPP_
3 changes: 3 additions & 0 deletions include/bolt/editor/debugger_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ class DebuggerInterface {
std::pair<std::string, size_t> find_line_for_pc(size_t pc) const;
std::string evaluate_watch_expression(const std::string& expression);
void setup_vm_handlers();
// Updates state, fires the event and adjusts the line highlight after a step_over/step_into/step_out.
void report_step_outcome(const std::string& breakpoint_message, const std::string& paused_message,
const std::string& completed_message);
};

} // namespace bolt
9 changes: 9 additions & 0 deletions include/bolt/editor/lsp_editor_bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,15 @@ class LspEditorBridge {
void handleDiagnostics(const std::string& uri, std::shared_ptr<JsonValue> diagnostics);
EditorCompletionItem convertCompletionItem(std::shared_ptr<JsonValue> item);
EditorDiagnostic convertDiagnostic(std::shared_ptr<JsonValue> diagnostic);

using OpenDocumentIterator = std::map<std::string, DocumentState>::iterator;
// Takes documentsMutex_, looks up filePath in openDocuments_, stores its language id in languageId and then
// calls visit (if any) on the entry with the lock still held. Returns false if the document is not open.
bool lookupOpenDocument(const std::string& filePath, std::string& languageId,
const std::function<void(OpenDocumentIterator)>& visit = nullptr);
// Returns the connected client for an open document, or nullptr if it is not open or has no connected client.
// Takes and releases documentsMutex_ before the client lookup.
LspClient* getConnectedClientForOpenDocument(const std::string& filePath);
Comment on lines +488 to +494

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 New helper comments omit Doxygen markup

lookupOpenDocument and getConnectedClientForOpenDocument use plain comments for their lock contracts. The other extracted helpers follow the same pattern despite the documentation rule.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

};

} // namespace lsp
Expand Down
2 changes: 2 additions & 0 deletions include/bolt/editor/split_view_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class SplitViewManager {

// Internal helpers
std::string generatePaneId();
// Shared implementation of createHorizontalSplit / createVerticalSplit.
std::string createSplit(const std::string& sourcePaneId, SplitDirection direction);
void notifyPaneOperation(PaneOperation op, const std::string& paneId);
bool isValidPaneId(const std::string& paneId) const;
void removePaneFromLayout(const std::string& paneId);
Expand Down
2 changes: 2 additions & 0 deletions include/bolt/editor/tab_bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class TabBar {
// Helper to find tab index by ID
std::optional<size_t> findTabIndexById(size_t tabId) const;
std::optional<size_t> findTabIndexByPath(const std::string& filePath) const;
// Shared implementation of activateNextTab (forward) / activatePreviousTab (backward), wrapping around.
void activateAdjacentTab(bool forward);
};

} // namespace bolt
Expand Down
Loading
Loading