CleanCocoa / CleanCocoa/DeclarativeTextKit
Command block that restores scroll offsets and selection like Emac Lisp save-excursion
- 主要言語
- Swift
- スター
- 50
- フォーク
- 0
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
> Note: This may not be needed in practice at all. We have to test this.
-------------
One feature that Emacs Lisp provides is to jump around in a buffer and read and write text, then restore the context exactly as it was before so that the user doesn't perceive anything. This is called `save-excursion`.
```swift
// Imagine we're in the middle of a long document here, like
// line 500 of 1000.
SaveExcursion {
Select(LineRange(at: 0)) {
// ... do stuff on the first line ...
}
Select(LineRange(at: buffer.endLocation)) {
// ... do stuff on the last line line ...
}
}
// At this point, we're at line 500 again and the scroll offset is the same as before
```
Unlike our `Buffer.character(at:)`, Emacs buffers can't access substrings without moving them into view. There, the buffer is the model, and moving the reading head also moves the scrolled viewport.
`NSTextView` can show similar behavior when you change characters in one place and attributes in a larger place and the effective range is enlargened; then the `NSTextStorage.processEditing()` run will move the insertion point:

Source and fix:
`UITextView` doesn't have this problem.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まずこの挙動が必要かどうかをテストし、次に issue で説明されている Buffer.character(at:) と NSTextStorage.processEditing() の挙動を調べます。実装方針を選ぶ前に、NSTextView と UITextView のケースを比較します。完了とは、この挙動が必要な場合に、コマンドがバッファを変更しながら以前の選択範囲とスクロールオフセットを復元できることを意味します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- swift
- 領域
- desktop-dev
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100