Repository: go-gitea/gitea
File: routers/web/repo/editor.go (Go)

Code before:
		defer dataRc.Close()

		ctx.Data["FileSize"] = fInfo.blobOrLfsSize

		// Only some file types are editable online as text.
		if fInfo.isLFSFile() {
			ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_lfs_files")
		} else if !fInfo.st.IsRepresentableAsText() {
			ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_non_text_files")
		} else if fInfo.blobOrLfsSize >= setting.UI.MaxDisplayFileSize {
			ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_too_large_file")
		}

		if ctx.Data["NotEditableReason"] == nil {
			buf, err := io.ReadAll(io.MultiReader(bytes.NewReader(prefetch), dataRc))
			if err != nil {
				ctx.ServerError("ReadAll", err)
				return
			}
			ctx.Data["FileContent"] = string(charset.ToUTF8(buf, charset.ConvertOpts{KeepBOM: true, ErrorReturnOrigin: true}))
		}
	}

	ecJSON, ecDef := getContextRepoEditorConfig(ctx, ctx.Repo.TreePath)
	ctx.Data["EditorconfigJson"] = ecJSON
	ctx.Data["EditorconfigIndentStyle"] = "space"
	ctx.Data["EditorconfigIndentSize"] = "4"
	if ecDef != nil {
		if ecDef.IndentStyle != "" {
			ctx.Data["EditorconfigIndentStyle"] = ecDef.IndentStyle
		}
		if ecDef.IndentSize != "" && ecDef.IndentSize != "tab" {
			ctx.Data["EditorconfigIndentSize"] = ecDef.IndentSize
		}
	}
	ctx.HTML(http.StatusOK, tplEditFile)
}

func EditFilePost(ctx *context.Context) {
	editorAction := ctx.PathParam("editor_action")
	isNewFile := editorAction == "_new"
	parsed := prepareEditorCommitSubmittedForm[*forms.EditRepoFileForm](ctx)
	if ctx.Written() {
		return
	}

	defaultCommitMessage := util.Iif(isNewFile, ctx.Locale.TrString("repo.editor.add", parsed.form.TreePath), ctx.Locale.TrString("repo.editor.update", parsed.form.TreePath))

	var operation string
	if isNewFile {
		operation = "create"

Review comment (suggestion):
```suggestion
	ctx.Data["EditorconfigIndentStyle"] = "space" // default value
```

Code after:

		// Only some file types are editable online as text.
		if fInfo.isLFSFile() {
			ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_lfs_files")
		} else if !fInfo.st.IsRepresentableAsText() {
			ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_non_text_files")
		} else if fInfo.blobOrLfsSize >= setting.UI.MaxDisplayFileSize {
			ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_too_large_file")
		}

		if ctx.Data["NotEditableReason"] == nil {
			buf, err := io.ReadAll(io.MultiReader(bytes.NewReader(prefetch), dataRc))
			if err != nil {
				ctx.ServerError("ReadAll", err)
				return
			}
			ctx.Data["FileContent"] = string(charset.ToUTF8(buf, charset.ConvertOpts{KeepBOM: true, ErrorReturnOrigin: true}))
		}
	}

	ctx.Data["CodeEditorConfig"] = getCodeEditorConfig(ctx, ctx.Repo.TreePath)
	ctx.HTML(http.StatusOK, tplEditFile)
}

func EditFilePost(ctx *context.Context) {
	editorAction := ctx.PathParam("editor_action")
	isNewFile := editorAction == "_new"
	parsed := prepareEditorCommitSubmittedForm[*forms.EditRepoFileForm](ctx)
	if ctx.Written() {
		return
	}

	defaultCommitMessage := util.Iif(isNewFile, ctx.Locale.TrString("repo.editor.add", parsed.form.TreePath), ctx.Locale.TrString("repo.editor.update", parsed.form.TreePath))

	var operation string
	if isNewFile {
		operation = "create"
	} else if parsed.form.Content.Has() {
		// The form content only has data if the file is representable as text, is not too large and not in lfs.
		operation = "update"
	} else if ctx.Repo.TreePath != parsed.form.TreePath {
		// If it doesn't have data, the only possible operation is a "rename"
		operation = "rename"
	} else {
		// It should never happen, just in case
		ctx.JSONError(ctx.Tr("error.occurred"))
		return
	}

	_, err := files_service.ChangeRepoFiles(ctx, ctx.Repo.Repository, ctx.Doer, &files_service.ChangeRepoFilesOptions{
		LastCommitID: parsed.form.LastCommit,