aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CellBuffer.cxx23
-rw-r--r--src/CellBuffer.h1
-rw-r--r--src/Document.cxx4
-rw-r--r--src/Document.h1
-rw-r--r--src/Editor.cxx4
-rw-r--r--src/Partitioning.h5
6 files changed, 38 insertions, 0 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index f02d5348a..d94ffaaea 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -71,6 +71,7 @@ public:
virtual void SetLineStart(Sci::Line line, Sci::Position position) noexcept = 0;
virtual void RemoveLine(Sci::Line line) = 0;
virtual Sci::Line Lines() const noexcept = 0;
+ virtual void AllocateLines(Sci::Line lines) = 0;
virtual Sci::Line LineFromPosition(Sci::Position pos) const noexcept = 0;
virtual Sci::Position LineStart(Sci::Line line) const noexcept = 0;
virtual void InsertCharacters(Sci::Line line, CountWidths delta) noexcept = 0;
@@ -132,6 +133,11 @@ public:
const Sci::Position widthCurrent = LineWidth(line);
starts.InsertText(static_cast<POS>(line), static_cast<POS>(width - widthCurrent));
}
+ void AllocateLines(Sci::Line lines) {
+ if (lines > starts.Partitions()) {
+ starts.ReAllocate(lines);
+ }
+ }
void InsertLines(Sci::Line line, Sci::Line lines) {
// Insert multiple lines with each temporarily 1 character wide.
// The line widths will be fixed up by later measuring code.
@@ -237,6 +243,17 @@ public:
Sci::Line Lines() const noexcept override {
return static_cast<Sci::Line>(starts.Partitions());
}
+ void AllocateLines(Sci::Line lines) override {
+ if (lines > Lines()) {
+ starts.ReAllocate(lines);
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf32)) {
+ startsUTF32.AllocateLines(lines);
+ }
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf16)) {
+ startsUTF16.AllocateLines(lines);
+ }
+ }
+ }
Sci::Line LineFromPosition(Sci::Position pos) const noexcept override {
return static_cast<Sci::Line>(starts.PartitionFromPosition(static_cast<POS>(pos)));
}
@@ -789,6 +806,10 @@ Sci::Line CellBuffer::Lines() const noexcept {
return plv->Lines();
}
+void CellBuffer::AllocateLines(Sci::Line lines) {
+ plv->AllocateLines(lines);
+}
+
Sci::Position CellBuffer::LineStart(Sci::Line line) const noexcept {
if (line < 0)
return 0;
@@ -903,7 +924,9 @@ bool CellBuffer::UTF8IsCharacterBoundary(Sci::Position position) const {
void CellBuffer::ResetLineEnds() {
// Reinitialize line data -- too much work to preserve
+ const Sci::Line lines = plv->Lines();
plv->Init();
+ plv->AllocateLines(lines);
constexpr Sci::Position position = 0;
const Sci::Position length = Length();
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index 637d0a6b5..be7957e99 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -191,6 +191,7 @@ public:
void AllocateLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex);
void ReleaseLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex);
Sci::Line Lines() const noexcept;
+ void AllocateLines(Sci::Line lines);
Sci::Position LineStart(Sci::Line line) const noexcept;
Sci::Position IndexLineStart(Sci::Line line, Scintilla::LineCharacterIndexType lineCharacterIndex) const noexcept;
Sci::Line LineFromPosition(Sci::Position pos) const noexcept;
diff --git a/src/Document.cxx b/src/Document.cxx
index 6194f772e..96bee868e 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -2266,6 +2266,10 @@ Sci::Line Document::LinesTotal() const noexcept {
return cb.Lines();
}
+void Document::AllocateLines(Sci::Line lines) {
+ cb.AllocateLines(lines);
+}
+
void Document::SetDefaultCharClasses(bool includeWordClass) {
charClass.SetDefaultCharClasses(includeWordClass);
}
diff --git a/src/Document.h b/src/Document.h
index fe27f4936..7984ad018 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -445,6 +445,7 @@ public:
void AllocateLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex);
void ReleaseLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex);
Sci::Line LinesTotal() const noexcept;
+ void AllocateLines(Sci::Line lines);
void SetDefaultCharClasses(bool includeWordClass);
void SetCharClasses(const unsigned char *chars, CharacterClass newCharClass);
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 5a0c153da..db7e2366e 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5988,6 +5988,10 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
else
return pdoc->LinesTotal();
+ case Message::AllocateLines:
+ pdoc->AllocateLines(wParam);
+ break;
+
case Message::GetModify:
return !pdoc->IsSavePoint();
diff --git a/src/Partitioning.h b/src/Partitioning.h
index cf1bb6a7b..efa6bf95e 100644
--- a/src/Partitioning.h
+++ b/src/Partitioning.h
@@ -110,6 +110,11 @@ public:
return static_cast<T>(body->Length())-1;
}
+ void ReAllocate(ptrdiff_t newSize) {
+ // + 1 accounts for initial element that is always 0.
+ body->ReAllocate(newSize + 1);
+ }
+
T Length() const noexcept {
return PositionFromPartition(Partitions());
}