CodeEditApp / CodeEditApp/CodeEditSourceEditor

✨ Code Folding

オープン
#43 コメント 8 件 リアクション 7 件 担当者 1 名 @thecoolwinter が担当を希望しています GitHub で見る
editor enhancement UI
主要言語
Swift
スター
719
フォーク
160
PR マージ指標
30日以内にマージされた PR はありません

説明

### Description

Code folding allows developers to collapse and expand sections of code (such as functions, classes, conditionals, and comments) to reduce visual clutter and focus on the parts they’re working on. This feature is particularly useful when navigating large files or deeply nested structures.

### Proposed Behavior

- Enable folding for code blocks such as:
- Functions and methods
- Classes and structs
- Loops and conditionals
- Multi-line comments and regions
- Display a vertical folding ribbon in the gutter next to line numbers, where users can click to collapse or expand blocks.
- Collapsed blocks should show an inline indicator with an expand toggle.
- Optionally, include editor commands for fold all / unfold all.

### Implementation Notes

- Can be powered by the existing Tree-sitter syntax trees to determine foldable ranges based on code structure.
- Should maintain fold state across file/tab switches and ideally across sessions.
- Folding ribbon interactions should be smooth and intuitive, with hover states and visual cues.
- Should add animation for folding and unfolding to make transitions feel natural and responsive.

### Benefits

- Reduces visual noise and helps maintain focus while editing.
- Makes it easier to navigate and manage large files.
- Provides a cleaner overview of structural code layout.

### Additional Context

The folding ribbon provides a familiar and discoverable UI for interacting with folded sections and complements keyboard or menu-based folding commands.

### Screenshots

https://user-images.githubusercontent.com/47652746/164981601-56c531e4-9420-4d46-96d7-f9d8456e5821.mov

Additional Screenshots

Screen Shot 2022-04-24 at 8 30 03 AM

Hover:
Screen Shot 2022-04-24 at 8 31 04 AM

Clicked (folded code):
Screen Shot 2022-04-24 at 8 31 40 AM

dark and light mode:
imgonline-com-ua-twotoone-0btV6nX2OfPxYH

### In Progress TODOs

- [x] Fold Ribbon
- [x] Draw nested folds
- [x] Draw adjacent folds with a horizontal line (instead of overlapping rounded edges)
- [x] Draw folded ranges
- [x] Fold Model
- [x] Generate folds from a provider for a document
- [x] Update folds as a document is edited
- [ ] Fold Providers
- [x] Line indent provider
- [ ] TreeSitter provider
- [ ] Perform Folding
- [x] Draw text attachment for fold range
- [ ] Animate folded text

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。