Skip to content

Commit 8342d68

Browse files
committed
Fix display of file content with empty line at beginning
In the previous solution, all files that would start with an empty line were not shown. This commit fixes that issue. Regresses 7576d1e
1 parent 2ee068f commit 8342d68

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/assets/javascripts/editor/editor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ var CodeOceanEditor = {
281281
this.setActiveFile($(element).parent().data('filename'), file_id);
282282

283283
const full_lines = content.text().split(/\n/);
284-
if (full_lines.length >= 1 && full_lines[0] !== "") {
284+
// Prevent inserting a single empty line, as the editor already contains one by default.
285+
if (full_lines.length > 1 || (full_lines.length === 1 && full_lines[0] !== "")) {
285286
document.insertFullLines(0, full_lines);
286287
// remove last (empty) that is there by default line
287288
document.removeFullLines(document.getLength() - 1, document.getLength() - 1);

0 commit comments

Comments
 (0)