fix #416 - editor whitespace marks for lines containing whitespace only

This commit is contained in:
Vadim Lopatin 2017-09-04 14:12:22 +03:00
parent 3181cbef09
commit 23d4a7406b
2 changed files with 4 additions and 3 deletions

View File

@ -999,7 +999,7 @@ class SDLWindow : Window {
if (flags & KeyFlag.Control || (flags & KeyFlag.LAlt) == KeyFlag.LAlt || flags & KeyFlag.Menu)
return true;
bool res = dispatchKeyEvent(new KeyEvent(KeyAction.Text, 0, flags, ds));
if (res) {
debug(DebugSDL) Log.d("Calling update() after text event");

View File

@ -2875,7 +2875,8 @@ class EditBox : EditWidgetBase {
lastNonSpace = i + 1;
}
}
if (firstNonSpace <= 0 && lastNonSpace >= txt.length && !hasTabs)
bool spacesOnly = txt.length > 0 && firstNonSpace < 0;
if (firstNonSpace <= 0 && lastNonSpace >= txt.length && !hasTabs && !spacesOnly)
return;
uint color = addAlpha(textColor, 0xC0);
static int[] textSizeBuffer;
@ -2888,7 +2889,7 @@ class EditBox : EditWidgetBase {
int spaceIndex = 0;
for (int i = 0; i < txt.length && i < charsMeasured; i++) {
dchar ch = txt[i];
bool outsideText = (i < firstNonSpace || i >= lastNonSpace);
bool outsideText = (i < firstNonSpace || i >= lastNonSpace || spacesOnly);
if ((ch == ' ' && outsideText) || ch == '\t') {
Rect rc = lineRect;
rc.left = lineRect.left + (i > 0 ? textSizeBuffer[i - 1] : 0);