An application can load all of a file into a buffer it allocates on a background thread and then add the data in that buffer
+@@ -5774,13 +5781,17 @@
+
+
To avoid these issues, a loader object may be created and used to load the file. The loader object supports the ILoader interface.
+
+-
+@@ -6573,7 +6584,7 @@
+ On GTK+, there are storage and performance costs to accessibility, so it can be disabled
+ by calling
SCI_SETACCESSIBILITY
.
+
+-
++
+
+
+
+@@ -6603,7 +6614,7 @@
+
+
+
+-
++
+
Lexer
+
+
If you define the symbol SCI_LEXER
when building Scintilla, (this is sometimes
+@@ -6894,7 +6905,7 @@
+
+ Methods that return strings as const char *
are not required to maintain separate allocations indefinitely:
+ lexer implementations may own a single buffer that is reused for each call.
+-Callers should make an immediate copy of returned strings.
++Callers should make an immediate copy of returned strings.
+
+
+
+diff -r a1731ae83d2a -r 92c8f0f1b3e6 include/Scintilla.h
+--- a/include/Scintilla.h Tue Jan 30 12:40:53 2018 +1100
++++ b/include/Scintilla.h Fri Jan 26 11:12:10 2018 +1100
+@@ -689,6 +689,7 @@
+ #define SCI_SELECTIONISRECTANGLE 2372
+ #define SCI_SETZOOM 2373
+ #define SCI_GETZOOM 2374
++#define SC_DOCUMENTOPTION_DEFAULT 0
+ #define SCI_CREATEDOCUMENT 2375
+ #define SCI_ADDREFDOCUMENT 2376
+ #define SCI_RELEASEDOCUMENT 2377
+diff -r a1731ae83d2a -r 92c8f0f1b3e6 include/Scintilla.iface
+--- a/include/Scintilla.iface Tue Jan 30 12:40:53 2018 +1100
++++ b/include/Scintilla.iface Fri Jan 26 11:12:10 2018 +1100
+@@ -1771,9 +1771,12 @@
+ # Retrieve the zoom level.
+ get int GetZoom=2374(,)
+
++enu DocumentOption=SC_DOCUMENTOPTION_
++val SC_DOCUMENTOPTION_DEFAULT=0
++
+ # Create a new document object.
+ # Starts with reference count of 1 and not selected into editor.
+-fun int CreateDocument=2375(,)
++fun int CreateDocument=2375(int bytes, int documentOption)
+ # Extend life of document.
+ fun void AddRefDocument=2376(, int doc)
+ # Release a reference to the document, deleting document if it fades to black.
+@@ -2540,7 +2543,7 @@
+ get int GetTechnology=2631(,)
+
+ # Create an ILoader*.
+-fun int CreateLoader=2632(int bytes,)
++fun int CreateLoader=2632(int bytes, int documentOption)
+
+ # On OS X, show a find indicator.
+ fun void FindIndicatorShow=2640(position start, position end)
+diff -r a1731ae83d2a -r 92c8f0f1b3e6 src/Editor.cxx
+--- a/src/Editor.cxx Tue Jan 30 12:40:53 2018 +1100
++++ b/src/Editor.cxx Fri Jan 26 11:12:10 2018 +1100
+@@ -7556,6 +7556,7 @@
+ case SCI_CREATEDOCUMENT: {
+ Document *doc = new Document();
+ doc->AddRef();
++ doc->Allocate(static_cast(wParam));
+ return reinterpret_cast(doc);
+ }
+
diff --git a/src/scintilla_backports/6442_3e3bfe29a819.patch b/src/scintilla_backports/6442_3e3bfe29a819.patch
new file mode 100644
index 00000000..acc6dbae
--- /dev/null
+++ b/src/scintilla_backports/6442_3e3bfe29a819.patch
@@ -0,0 +1,319 @@
+# HG changeset patch
+# User Neil
+# Date 1516950278 -39600
+# Node ID 3e3bfe29a819c1f7a1761096ec54e9b6ee446a68
+# Parent 92c8f0f1b3e64900cbb868a56936898693b9cfcc
+Extend SplitVector to allow more than 2 billion elements on 64-bit systems.
+
+diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/CellBuffer.cxx
+--- a/src/CellBuffer.cxx Fri Jan 26 11:12:10 2018 +1100
++++ b/src/CellBuffer.cxx Fri Jan 26 18:04:38 2018 +1100
+@@ -394,7 +394,7 @@
+ }
+
+ Sci::Position CellBuffer::GapPosition() const {
+- return substance.GapPosition();
++ return static_cast(substance.GapPosition());
+ }
+
+ // The char* returned is to an allocation owned by the undo history
+@@ -457,7 +457,7 @@
+ }
+
+ Sci::Position CellBuffer::Length() const {
+- return substance.Length();
++ return static_cast(substance.Length());
+ }
+
+ void CellBuffer::Allocate(Sci::Position newSize) {
+diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/Partitioning.h
+--- a/src/Partitioning.h Fri Jan 26 11:12:10 2018 +1100
++++ b/src/Partitioning.h Fri Jan 26 18:04:38 2018 +1100
+@@ -16,7 +16,7 @@
+
+ class SplitVectorWithRangeAdd : public SplitVector {
+ public:
+- explicit SplitVectorWithRangeAdd(int growSize_) {
++ explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) {
+ SetGrowSize(growSize_);
+ ReAllocate(growSize_);
+ }
+@@ -25,12 +25,12 @@
+ void operator=(const SplitVectorWithRangeAdd &) = delete;
+ ~SplitVectorWithRangeAdd() {
+ }
+- void RangeAddDelta(int start, int end, int delta) {
++ void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, int delta) {
+ // end is 1 past end, so end-start is number of elements to change
+- int i = 0;
+- const int rangeLength = end - start;
+- int range1Length = rangeLength;
+- const int part1Left = part1Length - start;
++ ptrdiff_t i = 0;
++ const ptrdiff_t rangeLength = end - start;
++ ptrdiff_t range1Length = rangeLength;
++ const ptrdiff_t part1Left = part1Length - start;
+ if (range1Length > part1Left)
+ range1Length = part1Left;
+ while (i < range1Length) {
+@@ -67,7 +67,7 @@
+ }
+ stepPartition = partitionUpTo;
+ if (stepPartition >= body->Length()-1) {
+- stepPartition = body->Length()-1;
++ stepPartition = Partitions();
+ stepLength = 0;
+ }
+ }
+@@ -80,7 +80,7 @@
+ stepPartition = partitionDownTo;
+ }
+
+- void Allocate(int growSize) {
++ void Allocate(ptrdiff_t growSize) {
+ body = new SplitVectorWithRangeAdd(growSize);
+ stepPartition = 0;
+ stepLength = 0;
+@@ -101,7 +101,7 @@
+ }
+
+ int Partitions() const {
+- return body->Length()-1;
++ return static_cast(body->Length()-1);
+ }
+
+ void InsertPartition(int partition, int pos) {
+@@ -132,7 +132,7 @@
+ BackStep(partitionInsert);
+ stepLength += delta;
+ } else {
+- ApplyStep(body->Length()-1);
++ ApplyStep(Partitions());
+ stepPartition = partitionInsert;
+ stepLength = delta;
+ }
+@@ -168,10 +168,10 @@
+ int PartitionFromPosition(int pos) const {
+ if (body->Length() <= 1)
+ return 0;
+- if (pos >= (PositionFromPartition(body->Length()-1)))
+- return body->Length() - 1 - 1;
++ if (pos >= (PositionFromPartition(Partitions())))
++ return Partitions() - 1;
+ int lower = 0;
+- int upper = body->Length()-1;
++ int upper = Partitions();
+ do {
+ const int middle = (upper + lower + 1) / 2; // Round high
+ int posMiddle = body->ValueAt(middle);
+diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/PerLine.cxx
+--- a/src/PerLine.cxx Fri Jan 26 11:12:10 2018 +1100
++++ b/src/PerLine.cxx Fri Jan 26 18:04:38 2018 +1100
+@@ -135,7 +135,7 @@
+ Sci::Line LineMarkers::MarkerNext(Sci::Line lineStart, int mask) const {
+ if (lineStart < 0)
+ lineStart = 0;
+- const Sci::Line length = markers.Length();
++ const Sci::Line length = static_cast(markers.Length());
+ for (Sci::Line iLine = lineStart; iLine < length; iLine++) {
+ const MarkerHandleSet *onLine = markers[iLine].get();
+ if (onLine && ((onLine->MarkValue() & mask) != 0))
+@@ -281,7 +281,7 @@
+ }
+
+ Sci::Line LineState::GetMaxLineState() const {
+- return lineStates.Length();
++ return static_cast(lineStates.Length());
+ }
+
+ static int NumberLines(const char *text) {
+diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/SplitVector.h
+--- a/src/SplitVector.h Fri Jan 26 11:12:10 2018 +1100
++++ b/src/SplitVector.h Fri Jan 26 18:04:38 2018 +1100
+@@ -16,15 +16,15 @@
+ protected:
+ T *body;
+- int size;
+- int lengthBody;
+- int part1Length;
+- int gapLength; /// invariant: gapLength == size - lengthBody
+- int growSize;
++ ptrdiff_t size;
++ ptrdiff_t lengthBody;
++ ptrdiff_t part1Length;
++ ptrdiff_t gapLength; /// invariant: gapLength == size - lengthBody
++ ptrdiff_t growSize;
+
+ /// Move the gap to a particular position so that insertion and
+ /// deletion at that point will not require much copying and
+ /// hence be fast.
+- void GapTo(int position) {
++ void GapTo(ptrdiff_t position) {
+ if (position != part1Length) {
+ if (position < part1Length) {
+ // Moving the gap towards start so moving elements towards end
+@@ -45,11 +45,11 @@
+
+ /// Check that there is room in the buffer for an insertion,
+ /// reallocating if more space needed.
+- void RoomFor(int insertionLength) {
++ void RoomFor(ptrdiff_t insertionLength) {
+ if (gapLength <= insertionLength) {
+ while (growSize < size / 6)
+ growSize *= 2;
+ ReAllocate(size + insertionLength + growSize);
+ }
+ }
+
+@@ -75,18 +75,18 @@
+ ~SplitVector() {
+ }
+
+- int GetGrowSize() const {
++ ptrdiff_t GetGrowSize() const {
+ return growSize;
+ }
+-
+- void SetGrowSize(int growSize_) {
++
++ void SetGrowSize(ptrdiff_t growSize_) {
+ growSize = growSize_;
+ }
+
+ /// Reallocate the storage for the buffer to be newSize and
+ /// copy exisiting contents to the new buffer.
+ /// Must not be used to decrease the size of the buffer.
+- void ReAllocate(int newSize) {
++ void ReAllocate(ptrdiff_t newSize) {
+ if (newSize < 0)
+ throw std::runtime_error("SplitVector::ReAllocate: negative size.");
+
+@@ -104,9 +104,9 @@
+
+ /// Retrieve the character at a particular position.
+ /// Retrieving positions outside the range of the buffer returns 0.
+ /// The assertions here are disabled since calling code can be
+ /// simpler if out of range access works and returns 0.
+- T ValueAt(int position) const {
++ T ValueAt(ptrdiff_t position) const {
+ if (position < part1Length) {
+ //PLATFORM_ASSERT(position >= 0);
+ if (position < 0) {
+@@ -124,7 +124,7 @@
+ }
+ }
+
+- void SetValueAt(int position, T v) {
++ void SetValueAt(ptrdiff_t position, T v) {
+ if (position < part1Length) {
+ PLATFORM_ASSERT(position >= 0);
+ if (position < 0) {
+@@ -144,7 +144,7 @@
+ }
+ }
+
+- T &operator[](int position) const {
++ T &operator[](ptrdiff_t position) const {
+ PLATFORM_ASSERT(position >= 0 && position < lengthBody);
+ if (position < part1Length) {
+ return body[position];
+@@ -166,13 +166,13 @@
+ }
+
+ /// Retrieve the length of the buffer.
+- int Length() const {
++ ptrdiff_t Length() const {
+ return lengthBody;
+ }
+
+ /// Insert a single value into the buffer.
+ /// Inserting at positions outside the current range fails.
+- void Insert(int position, T v) {
++ void Insert(ptrdiff_t position, T v) {
+ PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
+ if ((position < 0) || (position > lengthBody)) {
+ return;
+@@ -187,7 +187,7 @@
+
+ /// Insert a number of elements into the buffer setting their value.
+ /// Inserting at positions outside the current range fails.
+- void InsertValue(int position, int insertLength, T v) {
++ void InsertValue(ptrdiff_t position, ptrdiff_t insertLength, T v) {
+ PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
+ if (insertLength > 0) {
+ if ((position < 0) || (position > lengthBody)) {
+@@ -225,14 +225,14 @@
+
+ /// Ensure at least length elements allocated,
+ /// appending zero valued elements if needed.
+- void EnsureLength(int wantedLength) {
++ void EnsureLength(ptrdiff_t wantedLength) {
+ if (Length() < wantedLength) {
+ InsertValue(Length(), wantedLength - Length(), 0);
+ }
+ }
+
+ /// Insert text into the buffer from an array.
+- void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) {
++ void InsertFromArray(ptrdiff_t positionToInsert, const T s[], ptrdiff_t positionFrom, ptrdiff_t insertLength) {
+ PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody));
+ if (insertLength > 0) {
+ if ((positionToInsert < 0) || (positionToInsert > lengthBody)) {
+@@ -248,7 +248,7 @@
+ }
+
+ /// Delete one element from the buffer.
+- void Delete(int position) {
++ void Delete(ptrdiff_t position) {
+ PLATFORM_ASSERT((position >= 0) && (position < lengthBody));
+ if ((position < 0) || (position >= lengthBody)) {
+ return;
+@@ -258,7 +258,7 @@
+
+ /// Delete a range from the buffer.
+ /// Deleting positions outside the current range fails.
+- void DeleteRange(int position, int deleteLength) {
++ void DeleteRange(ptrdiff_t position, ptrdiff_t deleteLength) {
+ PLATFORM_ASSERT((position >= 0) && (position + deleteLength <= lengthBody));
+ if ((position < 0) || ((position + deleteLength) > lengthBody)) {
+ return;
+@@ -277,17 +277,17 @@
+ // Retrieve a range of elements into an array
+- void GetRange(T *buffer, int position, int retrieveLength) const {
++ void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const {
+ // Split into up to 2 ranges, before and after the split then use memcpy on each.
+- int range1Length = 0;
++ ptrdiff_t range1Length = 0;
+ if (position < part1Length) {
+- const int part1AfterPosition = part1Length - position;
++ const ptrdiff_t part1AfterPosition = part1Length - position;
+ range1Length = retrieveLength;
+ if (range1Length > part1AfterPosition)
+ range1Length = part1AfterPosition;
+ }
+ std::copy(body + position, body + position + range1Length, buffer);
+ buffer += range1Length;
+ position = position + range1Length + gapLength;
+- int range2Length = retrieveLength - range1Length;
++ ptrdiff_t range2Length = retrieveLength - range1Length;
+ std::copy(body + position, body + position + range2Length, buffer);
+ }
+
+@@ -308,7 +308,7 @@
+ return body;
+ }
+
+- T *RangePointer(int position, int rangeLength) {
++ T *RangePointer(ptrdiff_t position, ptrdiff_t rangeLength) {
+ if (position < part1Length) {
+ if ((position + rangeLength) > part1Length) {
+ // Range overlaps gap, so move gap to start of range.
+@@ -323,7 +323,7 @@
+ }
+ }
+
+- int GapPosition() const {
++ ptrdiff_t GapPosition() const {
+ return part1Length;
+ }
+ };
diff --git a/src/scintilla_backports/6444_1bd57324aa36.patch b/src/scintilla_backports/6444_1bd57324aa36.patch
new file mode 100644
index 00000000..93552ba4
--- /dev/null
+++ b/src/scintilla_backports/6444_1bd57324aa36.patch
@@ -0,0 +1,279 @@
+# HG changeset patch
+# User Neil
+# Date 1517436441 -39600
+# Node ID 1bd57324aa36e3fce1ed8a2371001b062322884b
+# Parent ab4efcbfdae68d1ec053db212edb1440326a7f1c
+Templatize Partitioning so it can hold different types.
+
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/CellBuffer.h
+--- a/src/CellBuffer.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/CellBuffer.h Thu Feb 01 09:07:21 2018 +1100
+@@ -24,7 +24,7 @@
+ */
+ class LineVector {
+
+- Partitioning starts;
++ Partitioning starts;
+ PerLine *perLine;
+
+ public:
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/ContractionState.cxx
+--- a/src/ContractionState.cxx Wed Jan 31 17:08:48 2018 +1100
++++ b/src/ContractionState.cxx Thu Feb 01 09:07:21 2018 +1100
+@@ -39,7 +39,7 @@
+ expanded = new RunStyles();
+ heights = new RunStyles();
+ foldDisplayTexts = new SparseVector();
+- displayLines = new Partitioning(4);
++ displayLines = new Partitioning(4);
+ InsertLines(0, linesInDocument);
+ }
+ }
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/ContractionState.h
+--- a/src/ContractionState.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/ContractionState.h Thu Feb 01 09:07:21 2018 +1100
+@@ -21,7 +21,7 @@
+ RunStyles *expanded;
+ RunStyles *heights;
+ SparseVector *foldDisplayTexts;
+- Partitioning *displayLines;
++ Partitioning *displayLines;
+ Sci::Line linesInDocument;
+
+ void EnsureData();
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/Partitioning.h
+--- a/src/Partitioning.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/Partitioning.h Thu Feb 01 09:07:21 2018 +1100
+@@ -14,29 +14,30 @@
+ /// in a range.
+ /// Used by the Partitioning class.
+
+-class SplitVectorWithRangeAdd : public SplitVector {
++template
++class SplitVectorWithRangeAdd : public SplitVector {
+ public:
+ explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) {
+- SetGrowSize(growSize_);
+- ReAllocate(growSize_);
++ this->SetGrowSize(growSize_);
++ this->ReAllocate(growSize_);
+ }
+ ~SplitVectorWithRangeAdd() {
+ }
+- void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, int delta) {
++ void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, T delta) {
+ // end is 1 past end, so end-start is number of elements to change
+ ptrdiff_t i = 0;
+ const ptrdiff_t rangeLength = end - start;
+ ptrdiff_t range1Length = rangeLength;
+- const ptrdiff_t part1Left = part1Length - start;
++ const ptrdiff_t part1Left = this->part1Length - start;
+ if (range1Length > part1Left)
+ range1Length = part1Left;
+ while (i < range1Length) {
+- body[start++] += delta;
++ this->body[start++] += delta;
+ i++;
+ }
+- start += gapLength;
++ start += this->gapLength;
+ while (i < rangeLength) {
+- body[start++] += delta;
++ this->body[start++] += delta;
+ i++;
+ }
+ }
+@@ -52,16 +53,17 @@
+ /// When needed, positions after the interval are considered part of the last partition
+ /// but the end of the last partition can be found with PositionFromPartition(last+1).
+
++template
+ class Partitioning {
+ private:
+ // To avoid calculating all the partition positions whenever any text is inserted
+ // there may be a step somewhere in the list.
+- int stepPartition;
+- int stepLength;
+- SplitVectorWithRangeAdd *body;
++ T stepPartition;
++ T stepLength;
++ SplitVectorWithRangeAdd *body;
+
+ // Move step forward
+- void ApplyStep(int partitionUpTo) {
++ void ApplyStep(T partitionUpTo) {
+ if (stepLength != 0) {
+ body->RangeAddDelta(stepPartition+1, partitionUpTo + 1, stepLength);
+ }
+@@ -73,7 +75,7 @@
+ }
+
+ // Move step backward
+- void BackStep(int partitionDownTo) {
++ void BackStep(T partitionDownTo) {
+ if (stepLength != 0) {
+ body->RangeAddDelta(partitionDownTo+1, stepPartition+1, -stepLength);
+ }
+@@ -81,7 +83,7 @@
+ }
+
+ void Allocate(ptrdiff_t growSize) {
+- body = new SplitVectorWithRangeAdd(growSize);
++ body = new SplitVectorWithRangeAdd(growSize);
+ stepPartition = 0;
+ stepLength = 0;
+ body->Insert(0, 0); // This value stays 0 for ever
+@@ -100,11 +102,11 @@
+ ~Partitioning() {
+ }
+
+- int Partitions() const {
+- return static_cast(body->Length()-1);
++ T Partitions() const {
++ return static_cast(body->Length())-1;
+ }
+
+- void InsertPartition(int partition, int pos) {
++ void InsertPartition(T partition, T pos) {
+ if (stepPartition < partition) {
+ ApplyStep(partition);
+ }
+@@ -112,7 +114,7 @@
+ stepPartition++;
+ }
+
+- void SetPartitionStartPosition(int partition, int pos) {
++ void SetPartitionStartPosition(T partition, T pos) {
+ ApplyStep(partition+1);
+ if ((partition < 0) || (partition > body->Length())) {
+ return;
+@@ -120,7 +122,7 @@
+ body->SetValueAt(partition, pos);
+ }
+
+- void InsertText(int partitionInsert, int delta) {
++ void InsertText(T partitionInsert, T delta) {
+ // Point all the partitions after the insertion point further along in the buffer
+ if (stepLength != 0) {
+ if (partitionInsert >= stepPartition) {
+@@ -142,7 +144,7 @@
+ }
+ }
+
+- void RemovePartition(int partition) {
++ void RemovePartition(T partition) {
+ if (partition > stepPartition) {
+ ApplyStep(partition);
+ stepPartition--;
+@@ -152,29 +154,29 @@
+ body->Delete(partition);
+ }
+
+- int PositionFromPartition(int partition) const {
++ T PositionFromPartition(T partition) const {
+ PLATFORM_ASSERT(partition >= 0);
+ PLATFORM_ASSERT(partition < body->Length());
+ if ((partition < 0) || (partition >= body->Length())) {
+ return 0;
+ }
+- int pos = body->ValueAt(partition);
++ T pos = body->ValueAt(partition);
+ if (partition > stepPartition)
+ pos += stepLength;
+ return pos;
+ }
+
+ /// Return value in range [0 .. Partitions() - 1] even for arguments outside interval
+- int PartitionFromPosition(int pos) const {
++ T PartitionFromPosition(T pos) const {
+ if (body->Length() <= 1)
+ return 0;
+ if (pos >= (PositionFromPartition(Partitions())))
+ return Partitions() - 1;
+- int lower = 0;
+- int upper = Partitions();
++ T lower = 0;
++ T upper = Partitions();
+ do {
+- const int middle = (upper + lower + 1) / 2; // Round high
+- int posMiddle = body->ValueAt(middle);
++ const T middle = (upper + lower + 1) / 2; // Round high
++ T posMiddle = body->ValueAt(middle);
+ if (middle > stepPartition)
+ posMiddle += stepLength;
+ if (pos < posMiddle) {
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/RunStyles.cxx
+--- a/src/RunStyles.cxx Wed Jan 31 17:08:48 2018 +1100
++++ b/src/RunStyles.cxx Thu Feb 01 09:07:21 2018 +1100
+@@ -70,7 +70,7 @@
+ }
+
+ RunStyles::RunStyles() {
+- starts = new Partitioning(8);
++ starts = new Partitioning(8);
+ styles = new SplitVector();
+ styles->InsertValue(0, 2, 0);
+ }
+@@ -204,7 +204,7 @@
+ starts = NULL;
+ delete styles;
+ styles = NULL;
+- starts = new Partitioning(8);
++ starts = new Partitioning(8);
+ styles = new SplitVector();
+ styles->InsertValue(0, 2, 0);
+ }
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/RunStyles.h
+--- a/src/RunStyles.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/RunStyles.h Thu Feb 01 09:07:21 2018 +1100
+@@ -14,7 +14,7 @@
+
+ class RunStyles {
+ private:
+- Partitioning *starts;
++ Partitioning *starts;
+ SplitVector *styles;
+ int RunFromPosition(int position) const;
+ int SplitRun(int position);
+diff -r ab4efcbfdae6 -r 1bd57324aa36 src/SparseVector.h
+--- a/src/SparseVector.h Wed Jan 31 17:08:48 2018 +1100
++++ b/src/SparseVector.h Thu Feb 01 09:07:21 2018 +1100
+@@ -15,7 +15,7 @@
+ template
+ class SparseVector {
+ private:
+- Partitioning *starts;
++ Partitioning *starts;
+ SplitVector *values;
+ // Private so SparseVector objects can not be copied
+ SparseVector(const SparseVector &);
+@@ -26,7 +26,7 @@
+ }
+ public:
+ SparseVector() {
+- starts = new Partitioning(8);
++ starts = new Partitioning(8);
+ values = new SplitVector();
+ values->InsertValue(0, 2, T());
+ }
+diff -r ab4efcbfdae6 -r 1bd57324aa36 test/unit/testPartitioning.cxx
+--- a/test/unit/testPartitioning.cxx Wed Jan 31 17:08:48 2018 +1100
++++ b/test/unit/testPartitioning.cxx Thu Feb 01 09:07:21 2018 +1100
+@@ -26,7 +26,7 @@
+
+ TEST_CASE("SplitVectorWithRangeAdd") {
+
+- SplitVectorWithRangeAdd svwra(growSize);
++ SplitVectorWithRangeAdd svwra(growSize);
+
+ SECTION("IsEmptyInitially") {
+ REQUIRE(0 == svwra.Length());
+@@ -49,7 +49,7 @@
+
+ TEST_CASE("Partitioning") {
+
+- Partitioning part(growSize);
++ Partitioning part(growSize);
+
+ SECTION("IsEmptyInitially") {
+ REQUIRE(1 == part.Partitions());
diff --git a/src/scintilla_backports/6445_89d992f380a1.patch b/src/scintilla_backports/6445_89d992f380a1.patch
new file mode 100644
index 00000000..b0b9acae
--- /dev/null
+++ b/src/scintilla_backports/6445_89d992f380a1.patch
@@ -0,0 +1,418 @@
+# HG changeset patch
+# User Neil
+# Date 1517437334 -39600
+# Node ID 89d992f380a1ce28a3ba6934230388ffaf1ea611
+# Parent 1bd57324aa36e3fce1ed8a2371001b062322884b
+Templatize RunStyles so it can be over ranges of different types and contain
+different style types.
+Currently only instantiated over .
+
+diff -r 1bd57324aa36 -r 89d992f380a1 src/ContractionState.cxx
+--- a/src/ContractionState.cxx Thu Feb 01 09:07:21 2018 +1100
++++ b/src/ContractionState.cxx Thu Feb 01 09:22:14 2018 +1100
+@@ -35,9 +35,9 @@
+
+ void ContractionState::EnsureData() {
+ if (OneToOne()) {
+- visible = new RunStyles();
+- expanded = new RunStyles();
+- heights = new RunStyles();
++ visible = new RunStyles();
++ expanded = new RunStyles();
++ heights = new RunStyles();
+ foldDisplayTexts = new SparseVector();
+ displayLines = new Partitioning(4);
+ InsertLines(0, linesInDocument);
+diff -r 1bd57324aa36 -r 89d992f380a1 src/ContractionState.h
+--- a/src/ContractionState.h Thu Feb 01 09:07:21 2018 +1100
++++ b/src/ContractionState.h Thu Feb 01 09:22:14 2018 +1100
+@@ -17,9 +17,9 @@
+ */
+ class ContractionState {
+ // These contain 1 element for every document line.
+- RunStyles *visible;
+- RunStyles *expanded;
+- RunStyles *heights;
++ RunStyles *visible;
++ RunStyles *expanded;
++ RunStyles *heights;
+ SparseVector *foldDisplayTexts;
+ Partitioning *displayLines;
+ Sci::Line linesInDocument;
+diff -r 1bd57324aa36 -r 89d992f380a1 src/Decoration.h
+--- a/src/Decoration.h Thu Feb 01 09:07:21 2018 +1100
++++ b/src/Decoration.h Thu Feb 01 09:22:14 2018 +1100
+@@ -12,7 +12,7 @@
+ class Decoration {
+ int indicator;
+ public:
+ Decoration *next;
+- RunStyles rs;
++ RunStyles rs;
+
+ explicit Decoration(int indicator_);
+diff -r 1bd57324aa36 -r 89d992f380a1 src/RunStyles.cxx
+--- a/src/RunStyles.cxx Thu Feb 01 09:07:21 2018 +1100
++++ b/src/RunStyles.cxx Thu Feb 01 09:22:14 2018 +1100
+@@ -26,8 +26,9 @@
+ using namespace Scintilla;
+
+ // Find the first run at a position
+-int RunStyles::RunFromPosition(int position) const {
+- int run = starts->PartitionFromPosition(position);
++template
++DISTANCE RunStyles::RunFromPosition(DISTANCE position) const {
++ DISTANCE run = starts->PartitionFromPosition(position);
+ // Go to first element with this position
+ while ((run > 0) && (position == starts->PositionFromPartition(run-1))) {
+ run--;
+@@ -36,11 +37,12 @@
+ }
+
+ // If there is no run boundary at position, insert one continuing style.
+-int RunStyles::SplitRun(int position) {
+- int run = RunFromPosition(position);
+- const int posRun = starts->PositionFromPartition(run);
++template
++DISTANCE RunStyles::SplitRun(DISTANCE position) {
++ DISTANCE run = RunFromPosition(position);
++ const DISTANCE posRun = starts->PositionFromPartition(run);
+ if (posRun < position) {
+- int runStyle = ValueAt(position);
++ STYLE runStyle = ValueAt(position);
+ run++;
+ starts->InsertPartition(run, position);
+ styles->InsertValue(run, 1, runStyle);
+@@ -48,12 +50,14 @@
+ return run;
+ }
+
+-void RunStyles::RemoveRun(int run) {
++template
++void RunStyles::RemoveRun(DISTANCE run) {
+ starts->RemovePartition(run);
+ styles->DeleteRange(run, 1);
+ }
+
+-void RunStyles::RemoveRunIfEmpty(int run) {
++template
++void RunStyles::RemoveRunIfEmpty(DISTANCE run) {
+ if ((run < starts->Partitions()) && (starts->Partitions() > 1)) {
+ if (starts->PositionFromPartition(run) == starts->PositionFromPartition(run+1)) {
+ RemoveRun(run);
+@@ -61,7 +65,8 @@
+ }
+ }
+
+-void RunStyles::RemoveRunIfSameAsPrevious(int run) {
++template
++void RunStyles::RemoveRunIfSameAsPrevious(DISTANCE run) {
+ if ((run > 0) && (run < starts->Partitions())) {
+ if (styles->ValueAt(run-1) == styles->ValueAt(run)) {
+ RemoveRun(run);
+@@ -69,34 +74,39 @@
+ }
+ }
+
+-RunStyles::RunStyles() {
+- starts = new Partitioning(8);
+- styles = new SplitVector();
++template
++RunStyles::RunStyles() {
++ starts = new Partitioning(8);
++ styles = new SplitVector