mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 11:33:34 +08:00
MarkdownToolBar: Make bold work with newlines
This commit is contained in:
@ -132,14 +132,15 @@ TextEditingValue modifyCurrentWord(
|
||||
}
|
||||
//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) {
|
||||
wordStartPos = 0;
|
||||
} else {
|
||||
wordStartPos += 1;
|
||||
}
|
||||
|
||||
var wordEndPos = text.indexOf(' ', cursorPos);
|
||||
var wordEndPos = text.indexOf(RegExp('\\s'), cursorPos);
|
||||
if (wordEndPos == -1) {
|
||||
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
|
||||
//
|
||||
|
Reference in New Issue
Block a user