Skip to content

Add code editor setting dropdowns#36534

Merged
wxiaoguang merged 33 commits intogo-gitea:mainfrom
silverwind:editoropts
Feb 11, 2026
Merged

Add code editor setting dropdowns#36534
wxiaoguang merged 33 commits intogo-gitea:mainfrom
silverwind:editoropts

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Feb 4, 2026

Adds three <select> controls on top right for indent style, indent size, and line wrap to the code editor (_edit), diff patch editor (_diffpatch) and git hook editor (/settings/hooks/git/pre-receive).

The git hooks editor is restyled to wrap the content in a box. Also included is a bugfix for the git hooks editor where monaco was not initialized correctly.

View with: https://github.com/go-gitea/gitea/pull/36534/changes?w=1

Screenshot 2026-02-10 at 05 46 20 Screenshot 2026-02-10 at 05 46 10 Screenshot 2026-02-10 at 05 48 10

Add `<select>` controls for indent style (spaces/tabs), indent size
(2/4/8), and line wrap mode to the code editor header. The git hooks
editor is restyled to include this new header. Also included it a bugfix
for the hooks editor where monaco was not configured correctly before.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 4, 2026
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/frontend labels Feb 4, 2026
@silverwind silverwind mentioned this pull request Feb 4, 2026
3 tasks
@silverwind silverwind added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 4, 2026
@silverwind silverwind requested a review from Copilot February 4, 2026 23:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds UI controls for configuring editor settings (indent style, indent size, and line wrap) to the code editor, git patch editor, and git hooks editor. It also includes a bugfix for the git hooks editor where Monaco was not configured with baseOptions before.

Changes:

  • Added select controls for indent style, indent size, and line wrap mode to all code editors
  • Refactored editorconfig data handling to pass slices instead of pre-joined strings to templates
  • Fixed git hooks editor to properly apply baseOptions
  • Simplified editorconfig indentation handling by keeping indentSize and tabSize in sync

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
web_src/js/features/codeeditor.ts Added indentSize: 'tabSize' to baseOptions, moved baseOptions application to createMonaco (fixing git hooks), added event listeners for editor settings controls, simplified editorconfig tab size handling
templates/repo/settings/githook_edit.tmpl Restructured to wrap content in form and include editor options in header
templates/repo/editor/patch.tmpl Added header structure with editor options controls
templates/repo/editor/options.tmpl New template containing select controls for indent style, indent size, and line wrap mode
templates/repo/editor/edit.tmpl Added flex layout to header and included editor options
routers/web/repo/editor_util.go Modified getContextRepoEditorConfig to return both JSON string and definition object
routers/web/repo/editor.go Updated to set EditorconfigIndentStyle and EditorconfigIndentSize context data, changed to pass slices instead of joined strings for PreviewableExtensions and LineWrapExtensions
options/locale/locale_en-US.json Added localization strings for editor settings controls
modules/templates/helper.go Added PathExt template function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: silverwind <me@silverwind.io>
Signed-off-by: silverwind <me@silverwind.io>
silverwind and others added 3 commits February 5, 2026 13:24
Signed-off-by: silverwind <me@silverwind.io>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@lunny
Copy link
Copy Markdown
Member

lunny commented Feb 6, 2026

It seems it used an original menu which has a different style with other menus?

@silverwind
Copy link
Copy Markdown
Member Author

Yes, this is because GitHub also uses bare <select> there. Could be refactored to Fomantic dropdown, but I'm not sure it's really necessary, some users may appreciate similarity.

Convert editor option selects from plain <select> elements to
div-based Fomantic UI dropdowns with tooltips showing the option
labels previously used as optgroup headers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member Author

Changed to use fomantic dropdowns:

Screenshot 2026-02-10 at 05 33 13 Screenshot 2026-02-10 at 05 33 08 Screenshot 2026-02-10 at 05 32 20

silverwind and others added 2 commits February 10, 2026 05:41
Selection dropdown menus connect flush to the dropdown box, so the
first item should not have rounded top corners.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevent font-weight and font-family from .ui.header parents
propagating into the editor option dropdowns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member Author

silverwind commented Feb 10, 2026

Fixed the border radius issue. There are more issues related to fomantic dropdowns like it resizing on open or the misaligned dropdown right border, but I will defer those to another time to not blow this PR out of scope.

@delvh
Copy link
Copy Markdown
Member

delvh commented Feb 10, 2026

Before reviewing, the general idea looks good.
What's the behavior on mobile?
Due to a lack of space I would recommend still merging them into one menu on mobile.

@silverwind
Copy link
Copy Markdown
Member Author

Mobile looks alright-ish:

image

I think we can reduce the size of these dropdowns a bit to match the "pills" above.

@silverwind
Copy link
Copy Markdown
Member Author

silverwind commented Feb 10, 2026

Mobile does not have enough space to fit this into one line. Maybe if the buttons before are reduced to just "Edit" and "Preview", then there might be enough space to fit a single dropdown but it will be hard if not impossible to condense the text enough.

Add small, compact classes and override min-height and padding to
bring dropdown height in line with adjacent menu items.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member Author

Adjusted heights:

Screenshot 2026-02-10 at 06 03 12 Screenshot 2026-02-10 at 06 02 35

@silverwind
Copy link
Copy Markdown
Member Author

All issues resolved. @wxiaoguang lgty?

Signed-off-by: silverwind <me@silverwind.io>
Signed-off-by: silverwind <me@silverwind.io>
@silverwind silverwind marked this pull request as ready for review February 11, 2026 17:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

silverwind and others added 7 commits February 11, 2026 19:37
Avoid overriding Monaco's indentation detection with a fallback
tabSize of 4 when EditorConfig doesn't define indent_style/indent_size.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Screen readers could announce these as unnamed comboboxes since
optgroup label is not a reliable accessible name. Add localized
aria-label attributes to each select element.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member Author

lgtm

@wxiaoguang wxiaoguang merged commit 47b3879 into go-gitea:main Feb 11, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Feb 11, 2026
@wxiaoguang wxiaoguang deleted the editoropts branch February 11, 2026 19:55
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 12, 2026
* origin/main: (34 commits)
  Fine tune diff highlighting (go-gitea#36592)
  Add code editor setting dropdowns (go-gitea#36534)
  Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588)
  Improve diff highlighting (go-gitea#36583)
  Fix markup code block layout (go-gitea#36578)
  Remove striped tables in UI (go-gitea#36509)
  Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570)
  Fix mirror sync parser and fix mirror messages (go-gitea#36504)
  Update JS and PY deps (go-gitea#36576)
  Add viewer controller for mermaid (zoom, drag) (go-gitea#36557)
  Misc typescript tweaks (go-gitea#36523)
  Use full-file highlighting for diff sections (go-gitea#36561)
  fix(diff): reprocess htmx content after loading more files (go-gitea#36568)
  [skip ci] Updated translations via Crowdin
  Add wrap to runner label list (go-gitea#36565)
  fix: add dnf5 command for Fedora in RPM package instructions (go-gitea#36527)
  Enable pagination on GiteaDownloader.getIssueReactions() (go-gitea#36549)
  Refactor merge conan and container auth preserve actions taskID (go-gitea#36560)
  Fix assignee sidebar links and empty placeholder after go-gitea#32465 refactor (go-gitea#36559)
  Fix various version parsing problems (go-gitea#36553)
  ...
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 12, 2026
* origin/main: (152 commits)
  Fine tune diff highlighting (go-gitea#36592)
  Add code editor setting dropdowns (go-gitea#36534)
  Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588)
  Improve diff highlighting (go-gitea#36583)
  Fix markup code block layout (go-gitea#36578)
  Remove striped tables in UI (go-gitea#36509)
  Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570)
  Fix mirror sync parser and fix mirror messages (go-gitea#36504)
  Update JS and PY deps (go-gitea#36576)
  Add viewer controller for mermaid (zoom, drag) (go-gitea#36557)
  Misc typescript tweaks (go-gitea#36523)
  Use full-file highlighting for diff sections (go-gitea#36561)
  fix(diff): reprocess htmx content after loading more files (go-gitea#36568)
  [skip ci] Updated translations via Crowdin
  Add wrap to runner label list (go-gitea#36565)
  fix: add dnf5 command for Fedora in RPM package instructions (go-gitea#36527)
  Enable pagination on GiteaDownloader.getIssueReactions() (go-gitea#36549)
  Refactor merge conan and container auth preserve actions taskID (go-gitea#36560)
  Fix assignee sidebar links and empty placeholder after go-gitea#32465 refactor (go-gitea#36559)
  Fix various version parsing problems (go-gitea#36553)
  ...
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 14, 2026
* origin/main: (2555 commits)
  automate updating nix flakes (go-gitea#35641)
  Update AGENTS.md instructions (go-gitea#36627)
  use user id in noreply emails (go-gitea#36550)
  feat(db): Improve BuildCaseInsensitiveLike with lowercase (go-gitea#36598)
  [skip ci] Updated translations via Crowdin
  BUG: Fix workflow run jobs API returning null steps (go-gitea#36603)
  Refactor highlight and diff (go-gitea#36599)
  Fix bug when do LFS GC (go-gitea#36500)
  feature to be able to filter project boards by milestones (go-gitea#36321)
  Update emoji data for Unicode 16 (go-gitea#36596)
  Adapt monaco error matching pattern to recent webpack config change (go-gitea#36533)
  Fix a bug user could change another user's primary email (go-gitea#36586)
  fix(repo-editor): disable Monaco `editContext` to avoid bugs with lost focus (go-gitea#36585)
  Fine tune diff highlighting (go-gitea#36592)
  Add code editor setting dropdowns (go-gitea#36534)
  Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588)
  Improve diff highlighting (go-gitea#36583)
  Fix markup code block layout (go-gitea#36578)
  Remove striped tables in UI (go-gitea#36509)
  Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570)
  ...

# Conflicts:
#	custom/conf/app.example.ini
#	docs/content/administration/config-cheat-sheet.en-us.md
#	docs/content/administration/config-cheat-sheet.zh-cn.md
#	modules/setting/security.go
#	routers/common/errpage.go
#	services/context/api.go
#	services/context/context.go
Sirherobrine23 pushed a commit to Sirherobrine23/gitea that referenced this pull request Mar 4, 2026
Adds three `<select>` controls on top right for indent style, indent
size, and line wrap to the code editor (`_edit`), diff patch editor
(`_diffpatch`) and git hook editor (`/settings/hooks/git/pre-receive`).

The git hooks editor is restyled to wrap the content in a box. Also
included is a bugfix for the git hooks editor where monaco was not
initialized correctly.

---------

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants