Add detailed migration plan for PieceTable-based buffer architecture.

- Created `piece-table-migration.md` outlining the steps to transition from GapBuffer to a unified PieceTable architecture.
- Included phased approach: extending PieceTable, Buffer adapter layer, command updates, and renderer changes.
- Detailed API changes, file updates, testing strategy, risk assessment, and timeline for each migration phase.
- Document serves as a reference for architecture goals and implementation details.
This commit is contained in:
2025-12-05 20:21:33 -08:00
parent 71c1c9e50b
commit 3f4c60d311
10 changed files with 3608 additions and 219 deletions

View File

@@ -6,6 +6,7 @@
#include <sstream>
#include <cmath>
#include <cctype>
#include <string_view>
#include "Command.h"
#include "syntax/HighlighterRegistry.h"
@@ -48,7 +49,7 @@ bool gFontDialogRequested = false;
// window based on the editor's current dimensions. The bottom row is reserved
// for the status line.
static std::size_t
compute_render_x(const std::string &line, const std::size_t curx, const std::size_t tabw)
compute_render_x(std::string_view line, const std::size_t curx, const std::size_t tabw)
{
std::size_t rx = 0;
for (std::size_t i = 0; i < curx && i < line.size(); ++i) {
@@ -93,10 +94,11 @@ ensure_cursor_visible(const Editor &ed, Buffer &buf)
}
// Horizontal scrolling (use rendered columns with tabs expanded)
std::size_t rx = 0;
const auto &lines = buf.Rows();
if (cury < lines.size()) {
rx = compute_render_x(static_cast<std::string>(lines[cury]), curx, 8);
std::size_t rx = 0;
const auto total = buf.Nrows();
if (cury < total) {
// Avoid materializing all rows and copying strings; get a zero-copy view
rx = compute_render_x(buf.GetLineView(cury), curx, 8);
}
if (rx < coloffs) {
coloffs = rx;