mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-13 14:40:54 +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;
|
||||
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);
|
||||
if (match == null) {
|
||||
//print("no match");
|
||||
|
@ -57,13 +57,12 @@ void main() {
|
||||
expect(result.cursorPos, 12);
|
||||
});
|
||||
|
||||
test('Adds a bullet point without spaces', () {
|
||||
test('Does not add a bullet point without spaces', () {
|
||||
var origText = "*One";
|
||||
var newText = origText + '\n';
|
||||
|
||||
var result = autoAddBulletList(origText, newText, newText.length);
|
||||
expect(result.text, "*One\n*");
|
||||
expect(result.cursorPos, result.text.length);
|
||||
expect(result, null);
|
||||
});
|
||||
|
||||
test('Adds a bullet point with many spaces', () {
|
||||
@ -101,5 +100,13 @@ void main() {
|
||||
expect(result.text, "* Hi There\n* ");
|
||||
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