abe33 / abe33/atom-pigments

Changes to TextEditor.onDidChange and TextBuffer.onDidChange coming in Atom 1.23

未關閉
#362 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
legacy-warning
主要語言
CoffeeScript
星號
518
分支
70
PR 合併指標
30 天內沒有已合併 PR

描述

Hi! Thanks for maintaining the pigments package!

In Atom v1.23, we will make [some](https://github.com/atom/text-buffer/pull/273) [changes](https://github.com/atom/text-buffer/pull/274) that may affect your package.

The methods `TextEditor.onDidChange` and `TextBuffer.onDidChange` will now call their callbacks *less frequently*. Previously, these callbacks would get called once for each individual change to the buffer. So if you had 5 cursors and typed a character, they would get called 5 times. Now, they will only get called once, and the event that is passed to them will contain information about *all 5* of the changes that have occurred.

The same properties that have always existed on the `TextBuffer.onDidChange` events (`oldRange`, `newRange`, `oldText`, and `newText`) will still be there, and they will now reflect the sum of *all* changes that have occurred. But now there will be an additional property called `changes`, which will contain an array of more fine-grained objects describing the *individual* changes. We encourage you to use this property instead of the old ones.

#### Effects on this package

It looks like this package calls the changed methods in the following places:

* `TextEditor.onDidChange`
* [here](https://github.com/abe33/atom-pigments/blob/916b836ae155f2f060bb9c36b3b18e2a383e9813/lib/color-buffer.coffee#L32)
* [here](https://github.com/abe33/atom-pigments/blob/916b836ae155f2f060bb9c36b3b18e2a383e9813/lib/color-buffer-element.coffee#L45)
* [here](https://github.com/abe33/atom-pigments/blob/916b836ae155f2f060bb9c36b3b18e2a383e9813/lib/color-buffer-element.coffee#L247)

We found these calls using a regex search, so this list might be incomplete, and it might contain some false positives.

#### What to do about the change

It is likely that you do not need to do anything. The old event properties will continue to work.

However, you may be able to handle changes more accurately and efficiently by using the `changes` field of the events rather than the old properties. The `changes` field does not exist in Atom 1.22 unless you use the `TextBuffer.onDidChangeText` method. In Atom 1.23 and above though, `.onDidChange` and `.onDidChangeText` will become identical, having both the old properties and the new `changes` property.

Please let me know if you have any questions. I would be happy to help!

貢獻指南

開啟貢獻指南

研究方向

該 issue 指出了 color-buffer.coffee 和 color-buffer-element.coffee 中呼叫 TextEditor.onDidChange 的三個具體行。先檢查這些檔案,以了解目前如何處理變更事件。接著更新事件處理常式,使其使用新的 'changes' 屬性來實現更準確、更有效率的處理,並確保與 Atom 1.23+ 相容。透過執行 package 的測試,或在 Atom 中手動測試這些變更,確認使用多個游標時色彩顯示仍能正確運作。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
coffeescript
領域
tooling
Issue 類型
重構
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。