aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2007-07-25 02:53:19 +0000
committernyamatongwe <devnull@localhost>2007-07-25 02:53:19 +0000
commitaaa03c79d3f42fb8bb603bce476af6838be02a4e (patch)
tree3d764bf555181cb56f3a0a180b60a816a51cdc49 /src
parent340983e94342aaf907025ba84c32f7017ceed579 (diff)
downloadscintilla-mirror-aaa03c79d3f42fb8bb603bce476af6838be02a4e.tar.gz
Fix bug #1404276 by wrapping the line which just had the character added
before ensuring the caret is visible. Also sets scroll bar in case line added by wrapping.
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx26
-rw-r--r--src/Editor.h1
2 files changed, 20 insertions, 7 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index b27775750..a8b6d6509 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1264,6 +1264,16 @@ void Editor::NeedWrapping(int docLineStart, int docLineEnd) {
}
}
+bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
+ AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap));
+ int linesWrapped = 1;
+ if (ll) {
+ LayoutLine(lineToWrap, surface, vs, ll, wrapWidth);
+ linesWrapped = ll->lines;
+ }
+ return cs.SetHeight(lineToWrap, linesWrapped);
+}
+
// Check if wrapping needed and perform any needed wrapping.
// fullwrap: if true, all lines which need wrapping will be done,
// in this single call.
@@ -1340,13 +1350,7 @@ bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) {
// Platform::DebugPrintf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, lineToWrap, lastLineToWrap);
// Platform::DebugPrintf("Pending wraps: %d to %d\n", wrapStart, wrapEnd);
while (lineToWrap < lastLineToWrap) {
- AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap));
- int linesWrapped = 1;
- if (ll) {
- LayoutLine(lineToWrap, surface, vs, ll, wrapWidth);
- linesWrapped = ll->lines;
- }
- if (cs.SetHeight(lineToWrap, linesWrapped)) {
+ if (WrapOneLine(surface, lineToWrap)) {
wrapOccurred = true;
}
lineToWrap++;
@@ -3306,6 +3310,14 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
if (charReplaceAction) {
pdoc->EndUndoAction();
}
+ // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
+ if (wrapState != eWrapNone) {
+ AutoSurface surface(this);
+ if (surface) {
+ WrapOneLine(surface, pdoc->LineFromPosition(currentPos));
+ }
+ SetScrollBars();
+ }
EnsureCaretVisible();
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
diff --git a/src/Editor.h b/src/Editor.h
index 2115af7d9..049cc373f 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -299,6 +299,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void UpdateSystemCaret();
void NeedWrapping(int docLineStart = 0, int docLineEnd = wrapLineLarge);
+ bool WrapOneLine(Surface *surface, int lineToWrap);
bool WrapLines(bool fullWrap, int priorityWrapLineStart);
void LinesJoin();
void LinesSplit(int pixelWidth);