mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-03 23:00:04 +08:00
MarkdownToolBar: Make bold work with newlines
This commit is contained in:
@ -132,14 +132,15 @@ TextEditingValue modifyCurrentWord(
|
|||||||
}
|
}
|
||||||
//print('CursorPos: $cursorPos');
|
//print('CursorPos: $cursorPos');
|
||||||
|
|
||||||
var wordStartPos = text.lastIndexOf(' ', cursorPos == 0 ? 0 : cursorPos - 1);
|
var wordStartPos =
|
||||||
|
text.lastIndexOf(RegExp('\\s'), cursorPos == 0 ? 0 : cursorPos - 1);
|
||||||
if (wordStartPos == -1) {
|
if (wordStartPos == -1) {
|
||||||
wordStartPos = 0;
|
wordStartPos = 0;
|
||||||
} else {
|
} else {
|
||||||
wordStartPos += 1;
|
wordStartPos += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var wordEndPos = text.indexOf(' ', cursorPos);
|
var wordEndPos = text.indexOf(RegExp('\\s'), cursorPos);
|
||||||
if (wordEndPos == -1) {
|
if (wordEndPos == -1) {
|
||||||
wordEndPos = text.length;
|
wordEndPos = text.length;
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,16 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Surrounds the middle word with a newline", () {
|
||||||
|
_testWord(
|
||||||
|
before: 'Hello\nHydra Person',
|
||||||
|
beforeOffset: 8,
|
||||||
|
after: 'Hello\n**Hydra** Person',
|
||||||
|
afterOffset: 13,
|
||||||
|
char: '**',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
// Navigation
|
// Navigation
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user