Skip to content

Improve code editor text selection and clean up lint enablement#37474

Merged
bircni merged 3 commits intogo-gitea:mainfrom
silverwind:code-editor-selection-and-lint
May 1, 2026
Merged

Improve code editor text selection and clean up lint enablement#37474
bircni merged 3 commits intogo-gitea:mainfrom
silverwind:code-editor-selection-and-lint

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Apr 28, 2026

  1. Make the content area stretch the box, enabling text selection to start over empty space.
  2. Disable linter for markdown, it can never produce lint errors, this hides the unnecessary lint gutter on markdown files.
  3. Verified all languages linter enablement, all accurate.
  4. Refactor getLinterExtension to not rely on file extensions.
  5. Include jsonc/json5 extensions in regex.

This PR was written with the help of Claude Opus 4.7

Make `.cm-content` fill the editor area via flex stretching so mousedown
in the blank space below the last line starts a text selection.

Drop the empty lint gutter for markdown: its hand-written parser emits
no error nodes, and nested code-fence parsers are mounted as overlays
which the syntax-error linter does not traverse.

Switch linter routing from extension matching to `Language.name`, and
widen the loose-JSON regex to cover `.jsonc`/`.json5`, which previously
fell through to the strict syntax-error linter.

Co-Authored-By: Claude (Opus 4.7) <[email protected]>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 28, 2026
Files like `tsconfig.JSON` or `foo.JSONC` previously fell through the
loose-JSON branch and got the strict JSON linter. The old extension-based
code had the same bug; fix it while we're here.

Co-Authored-By: Claude (Opus 4.7) <[email protected]>
@silverwind silverwind added the type/enhancement An improvement of existing functionality label Apr 28, 2026
@silverwind silverwind changed the title Fix code editor text selection and clean up lint gutter routing Fix code editor text selection and clean up lint enablement Apr 28, 2026
@silverwind silverwind requested a review from Copilot April 28, 2026 22:49
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 adjusts the web CodeMirror editor’s layout and linter enablement to improve UX (text selection on empty editor space) and reduce unnecessary lint UI (especially for Markdown / JSONC-like files).

Changes:

  • Update editor CSS layout to ensure the content area stretches, allowing text selection to begin on empty space.
  • Refactor linter selection to use the loaded CodeMirror language (and disable lint gutter for Markdown / StreamLanguage modes).
  • Expand JSONC detection to cover .jsonc/.json5 in addition to specific .json basenames.

Reviewed changes

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

File Description
web_src/js/modules/codeeditor/main.ts Refactors linter-extension selection using LanguageSupport, disables lint gutter for markdown, and updates JSONC/JSON5 detection.
web_src/css/modules/codeeditor.css Switches editor container to a flex layout and stretches .cm-content to fill the editor for improved selection behavior.

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

Comment thread web_src/js/modules/codeeditor/main.ts
@silverwind silverwind changed the title Fix code editor text selection and clean up lint enablement Improve code editor text selection and clean up lint enablement Apr 29, 2026
@lunny lunny added this to the 1.27.0 milestone Apr 29, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 29, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 1, 2026
@bircni bircni enabled auto-merge (squash) May 1, 2026 17:36
@bircni bircni merged commit 31cee60 into go-gitea:main May 1, 2026
22 checks passed
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. type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants