Skip to content

Commit

Permalink
feat: fix paste error in CodeBlockNode
Browse files Browse the repository at this point in the history
  • Loading branch information
asjqkkkk committed Jun 25, 2024
1 parent 60f6c52 commit f48fbfa
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/editor/node/code_block/generator/paste.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ NodeWithCursor pasteWhileEditing(
throw NodeUnsupportedException(
node.runtimeType, 'pasteWhileEditing', nodes);
}
final newCodes = nodes.map((e) => e.text).toList();
final newCodes = <String>[];
for (var n in nodes) {
if (n is CodeBlockNode) {
newCodes.addAll(n.codes);
} else {
newCodes.add(n.text.trim());
}
}
final p = data.position;
final codes = node.codes;
final code = codes[p.index];
Expand Down Expand Up @@ -41,7 +48,14 @@ NodeWithCursor pasteWhileSelecting(
throw PasteToCreateMoreNodesException(
nodes, node.runtimeType, nodes.last.endPosition);
}
final newCodes = nodes.map((e) => e.text).toList();
final newCodes = <String>[];
for (var n in nodes) {
if (n is CodeBlockNode) {
newCodes.addAll(n.codes);
} else {
newCodes.add(n.text.trim());
}
}
bool oneLine = newCodes.length == 1;
final lastCodeLength = newCodes.last.length;
final newPosition = CodeBlockPosition(p.left.index + newCodes.length - 1,
Expand Down

0 comments on commit f48fbfa

Please sign in to comment.