mirror of
https://github.com/heyman/heynote.git
synced 2024-11-29 11:24:04 +01:00
When moving all lines from the last block upwards, make sure we don't create a block with empty block content (which will create an invalid syntax tree)
#windows-build
This commit is contained in:
parent
a3545f5b52
commit
428a3172ab
@ -42,7 +42,8 @@ function moveLine(state, dispatch, forward) {
|
|||||||
// if the whole selection is a block (surrounded by separators) we need to add an extra line break between the separators that'll
|
// if the whole selection is a block (surrounded by separators) we need to add an extra line break between the separators that'll
|
||||||
// get stacked on top of each other, since we'll otherwise create two separators with only a single line break between them which
|
// get stacked on top of each other, since we'll otherwise create two separators with only a single line break between them which
|
||||||
// the syntax parser won't be able to parse (since a valid separator needs one line break on each side)
|
// the syntax parser won't be able to parse (since a valid separator needs one line break on each side)
|
||||||
let blockSurroundedBySeparators = previousLine !== null && previousLine.text.match(tokenRegEx) && nextLine.text.match(tokenRegEx)
|
let nextLineIsSeparator = nextLine.text.match(tokenRegEx)
|
||||||
|
let blockSurroundedBySeparators = previousLine !== null && previousLine.text.match(tokenRegEx) && nextLineIsSeparator
|
||||||
let size = nextLine.length + 1;
|
let size = nextLine.length + 1;
|
||||||
if (forward) {
|
if (forward) {
|
||||||
if (blockSurroundedBySeparators) {
|
if (blockSurroundedBySeparators) {
|
||||||
@ -55,7 +56,7 @@ function moveLine(state, dispatch, forward) {
|
|||||||
ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));
|
ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (blockSurroundedBySeparators) {
|
if (blockSurroundedBySeparators || (previousLine === null && nextLineIsSeparator)) {
|
||||||
//size += 1
|
//size += 1
|
||||||
changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text + state.lineBreak});
|
changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text + state.lineBreak});
|
||||||
for (let r of block.ranges)
|
for (let r of block.ranges)
|
||||||
|
Loading…
Reference in New Issue
Block a user