mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 09:06:43 +08:00
Auto add numbered lists when typing
Since we're using markdown it's kinda awesome that we can re-use the same last number and markdown will arrange the numbers properly.
This commit is contained in:
@ -21,7 +21,7 @@ EditorHeuristicResult autoAddBulletList(
|
||||
prevLineStart = prevLineStart == -1 ? 0 : prevLineStart + 1;
|
||||
var prevLine = curText.substring(prevLineStart, cursorPos - 1);
|
||||
|
||||
var pattern = RegExp(r'^(\s*)([*\-])');
|
||||
var pattern = RegExp(r'^(\s*)([*\-]|[0-9]\.)');
|
||||
var match = pattern.firstMatch(prevLine);
|
||||
if (match == null) {
|
||||
return null;
|
||||
|
@ -28,5 +28,14 @@ void main() {
|
||||
expect(result.text, "Hello\n* One\n* \n* Three");
|
||||
expect(result.cursorPos, 14);
|
||||
});
|
||||
|
||||
test('Adds a numbered list at the end', () {
|
||||
var origText = "Hello\n1. One";
|
||||
var newText = "Hello\n1. One\n";
|
||||
|
||||
var result = autoAddBulletList(origText, newText, newText.length);
|
||||
expect(result.text, "Hello\n1. One\n1. ");
|
||||
expect(result.cursorPos, result.text.length);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user