From cf44789a0089570c85505ad9881be2f0801c81a2 Mon Sep 17 00:00:00 2001 From: bytedream Date: Sat, 3 May 2025 03:20:22 +0200 Subject: [PATCH] Fix new file not being editable --- routers/web/repo/editor.go | 4 +++- templates/repo/editor/edit.tmpl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index 542ba93e74..5df7a1bbcc 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -161,7 +161,7 @@ func editFile(ctx *context.Context, isNewFile bool) { buf = buf[:n] // Only some file types are editable online as text. - ctx.Data["IsFileText"] = typesniffer.DetectContentType(buf).IsRepresentableAsText() + ctx.Data["IsFileEditable"] = typesniffer.DetectContentType(buf).IsRepresentableAsText() if blob.Size() >= setting.UI.MaxDisplayFileSize { ctx.Data["IsFileTooLarge"] = true @@ -179,6 +179,8 @@ func editFile(ctx *context.Context, isNewFile bool) { } else { // Append filename from query, or empty string to allow username the new file. treeNames = append(treeNames, fileName) + + ctx.Data["IsFileEditable"] = true } ctx.Data["TreeNames"] = treeNames diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index 9a59fdac70..0c452661e3 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -28,7 +28,7 @@ - {{if .IsFileText}} + {{if .IsFileEditable}}