mirror of https://github.com/buggins/dlangui.git
fix for matching brackets support in editors
This commit is contained in:
parent
f703b74408
commit
7d7dc6faee
|
@ -784,29 +784,32 @@ class EditableContent {
|
||||||
|
|
||||||
/// returns previous character position
|
/// returns previous character position
|
||||||
TextPosition prevCharPos(TextPosition p) {
|
TextPosition prevCharPos(TextPosition p) {
|
||||||
|
if (p.line <= 0)
|
||||||
|
return TextPosition(0, 0);
|
||||||
|
p.pos--;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (p.line <= 0)
|
if (p.line <= 0)
|
||||||
return TextPosition(0, 0);
|
return TextPosition(0, 0);
|
||||||
if (p.pos > 0) {
|
if (p.pos >= 0 && p.pos < lineLength(p.line))
|
||||||
p.pos--;
|
|
||||||
return p;
|
return p;
|
||||||
}
|
p.line--;
|
||||||
p = lineEnd(p.line - 1);
|
p.pos = lineLength(p.line) - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns previous character position
|
/// returns previous character position
|
||||||
TextPosition nextCharPos(TextPosition p) {
|
TextPosition nextCharPos(TextPosition p) {
|
||||||
TextPosition eof = endOfFile();
|
TextPosition eof = endOfFile();
|
||||||
|
if (p >= eof)
|
||||||
|
return eof;
|
||||||
|
p.pos++;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (p >= eof)
|
if (p >= eof)
|
||||||
return eof;
|
return eof;
|
||||||
int len = lineLength(p.line);
|
if (p.pos >= 0 && p.pos < lineLength(p.line))
|
||||||
if (p.pos < len) {
|
|
||||||
p.pos++;
|
|
||||||
return p;
|
return p;
|
||||||
}
|
p.line++;
|
||||||
p = lineBegin(p.line + 1);
|
p.pos = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue