aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CellBuffer.cxx16
-rw-r--r--src/CellBuffer.h4
2 files changed, 12 insertions, 8 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index de499ad68..d349040f0 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -44,9 +44,11 @@ void LineVector::InsertText(int line, int delta) {
starts.InsertText(line, delta);
}
-void LineVector::InsertLine(int line, int position) {
+void LineVector::InsertLine(int line, int position, bool lineStart) {
starts.InsertPartition(line, position);
if (perLine) {
+ if ((line > 0) && lineStart)
+ line--;
perLine->InsertLine(line);
}
}
@@ -473,8 +475,8 @@ bool CellBuffer::IsSavePoint() {
// Without undo
-void CellBuffer::InsertLine(int line, int position) {
- lv.InsertLine(line, position);
+void CellBuffer::InsertLine(int line, int position, bool lineStart) {
+ lv.InsertLine(line, position, lineStart);
}
void CellBuffer::RemoveLine(int line) {
@@ -490,30 +492,32 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
style.InsertValue(position, insertLength, 0);
int lineInsert = lv.LineFromPosition(position) + 1;
+ bool atLineStart = lv.LineStart(lineInsert-1) == position;
// Point all the lines after the insertion point further along in the buffer
lv.InsertText(lineInsert-1, insertLength);
char chPrev = substance.ValueAt(position - 1);
char chAfter = substance.ValueAt(position + insertLength);
if (chPrev == '\r' && chAfter == '\n') {
// Splitting up a crlf pair at position
- InsertLine(lineInsert, position);
+ InsertLine(lineInsert, position, false);
lineInsert++;
}
char ch = ' ';
for (int i = 0; i < insertLength; i++) {
ch = s[i];
if (ch == '\r') {
- InsertLine(lineInsert, (position + i) + 1);
+ InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++;
} else if (ch == '\n') {
if (chPrev == '\r') {
// Patch up what was end of line
lv.SetLineStart(lineInsert - 1, (position + i) + 1);
} else {
- InsertLine(lineInsert, (position + i) + 1);
+ InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++;
}
}
+ atLineStart = false;
chPrev = ch;
}
// Joining two lines where last insertion is cr and following substance starts with lf
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index 93202c9b5..a94a9dc38 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -37,7 +37,7 @@ public:
void SetPerLine(PerLine *pl);
void InsertText(int line, int delta);
- void InsertLine(int line, int position);
+ void InsertLine(int line, int position, bool lineStart);
void SetLineStart(int line, int position);
void RemoveLine(int line);
int Lines() const {
@@ -159,7 +159,7 @@ public:
int Lines() const;
int LineStart(int line) const;
int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); }
- void InsertLine(int line, int position);
+ void InsertLine(int line, int position, bool lineStart);
void RemoveLine(int line);
const char *InsertString(int position, const char *s, int insertLength, bool &startSequence);