mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00
Bug: Typing '---' + Enter creates a new list
This commit is contained in:
@ -34,7 +34,7 @@ EditorHeuristicResult autoAddBulletList(
|
|||||||
prevLineStart = prevLineStart == -1 ? 0 : prevLineStart + 1;
|
prevLineStart = prevLineStart == -1 ? 0 : prevLineStart + 1;
|
||||||
var prevLine = curText.substring(prevLineStart, cursorPos - 1);
|
var prevLine = curText.substring(prevLineStart, cursorPos - 1);
|
||||||
|
|
||||||
var pattern = RegExp(r'^(\s*)([*\-]|[0-9]\.)(\s*)(.*)$');
|
var pattern = RegExp(r'^(\s*)([*\-]|[0-9]\.)(\s+)(.*)$');
|
||||||
var match = pattern.firstMatch(prevLine);
|
var match = pattern.firstMatch(prevLine);
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
//print("no match");
|
//print("no match");
|
||||||
|
@ -57,13 +57,12 @@ void main() {
|
|||||||
expect(result.cursorPos, 12);
|
expect(result.cursorPos, 12);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Adds a bullet point without spaces', () {
|
test('Does not add a bullet point without spaces', () {
|
||||||
var origText = "*One";
|
var origText = "*One";
|
||||||
var newText = origText + '\n';
|
var newText = origText + '\n';
|
||||||
|
|
||||||
var result = autoAddBulletList(origText, newText, newText.length);
|
var result = autoAddBulletList(origText, newText, newText.length);
|
||||||
expect(result.text, "*One\n*");
|
expect(result, null);
|
||||||
expect(result.cursorPos, result.text.length);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Adds a bullet point with many spaces', () {
|
test('Adds a bullet point with many spaces', () {
|
||||||
@ -101,5 +100,13 @@ void main() {
|
|||||||
expect(result.text, "* Hi There\n* ");
|
expect(result.text, "* Hi There\n* ");
|
||||||
expect(result.cursorPos, result.text.length);
|
expect(result.cursorPos, result.text.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Triple dashs', () {
|
||||||
|
var origText = "---";
|
||||||
|
var newText = origText + '\n';
|
||||||
|
|
||||||
|
var result = autoAddBulletList(origText, newText, newText.length);
|
||||||
|
expect(result, null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user