mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
Editor Heurisitics: Should work even if the items have spaces
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*)([^\s]*)$');
|
||||
var pattern = RegExp(r'^(\s*)([*\-]|[0-9]\.)(\s*)(.*)$');
|
||||
var match = pattern.firstMatch(prevLine);
|
||||
if (match == null) {
|
||||
//print("no match");
|
||||
|
@ -74,15 +74,31 @@ void main() {
|
||||
expect(result.cursorPos, result.text.length);
|
||||
});
|
||||
|
||||
/*
|
||||
test('Adds a numbered list in the first line', () {
|
||||
var origText = "1. Hello";
|
||||
var newText = origText + '\n';
|
||||
|
||||
var result = autoAddBulletList(origText, newText, newText.length);
|
||||
expect(result.text, "1. Hello\n1. ");
|
||||
expect(result.cursorPos, result.text.length);
|
||||
});
|
||||
|
||||
test('Adds a bullet point with many spaces - in the middle', () {
|
||||
var origText = "* One\nFire";
|
||||
var newText = origText + '\n';
|
||||
var newText = "* One\n\nFire";
|
||||
|
||||
var result = autoAddBulletList(origText, newText, 8);
|
||||
expect(result.text, "* One\n* \nFire");
|
||||
expect(result.cursorPos, 12);
|
||||
});
|
||||
*/
|
||||
|
||||
test('Works with item with spaces', () {
|
||||
var origText = "* Hi There";
|
||||
var newText = origText + '\n';
|
||||
|
||||
var result = autoAddBulletList(origText, newText, newText.length);
|
||||
expect(result.text, "* Hi There\n* ");
|
||||
expect(result.cursorPos, result.text.length);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user