Skip to content

Commit 869f79a

Browse files
committed
fix: remove extra line after drag-drop operation
1 parent c3005e3 commit 869f79a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/LiveDevelopment/LivePreviewEdit.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ define(function (require, exports, module) {
175175
// first, we need to remove the source code from its initial position
176176
editor.replaceRange("", sourceRange.from, sourceRange.to);
177177

178+
// since we remove content from the source, we want to clear the extra line
179+
if(sourceRange.from.line !== 0) {
180+
const prevLineText = editor.getLine(sourceRange.from.line - 1);
181+
const chPrevLine = prevLineText ? prevLineText.length : 0;
182+
editor.replaceRange("", {line: sourceRange.from.line - 1, ch: chPrevLine}, sourceRange.from);
183+
}
184+
178185
// recalculate the target range, as the source text is not removed
179186
const updatedTargetRange = HTMLInstrumentation.getPositionFromTagId(editor, targetId);
180187
if (!updatedTargetRange) {

0 commit comments

Comments
 (0)