Skip to content

Commit 4362b97

Browse files
committed
fix: indentation not consistent after drag-drop
1 parent b9d37ee commit 4362b97

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/LiveDevelopment/LivePreviewEdit.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,14 @@ define(function (require, exports, module) {
375375
};
376376

377377
const sourceText = editor.getTextBetween(sourceRangeObj.from, sourceRangeObj.to);
378-
const targetIndent = editor.getTextBetween({ line: targetRangeObj.from.line, ch: 0 }, targetRangeObj.from);
378+
let targetIndent = editor.getTextBetween({ line: targetRangeObj.from.line, ch: 0 }, targetRangeObj.from);
379+
if(targetIndent && targetIndent.trim() !== "") { // because indentation should hold no text
380+
let indentLength = targetIndent.search(/\S/);
381+
if (indentLength === -1) {
382+
indentLength = targetIndent.length;
383+
}
384+
targetIndent = ' '.repeat(indentLength);
385+
}
379386

380387
// Check if source is before target to determine order of operations
381388
// check if the source is before target or after the target

0 commit comments

Comments
 (0)