Add support for indirect buffers#276
Conversation
8c6969d to
6915bc4
Compare
- Add diff-hl--buffer-file-name helper to retrieve the file name of the current buffer or its base buffer. - Replace direct accesses of the buffer-file-name variable with the new helper changes to all live buffers sharing the same base buffer.
6915bc4 to
1256073
Compare
|
Try removing the |
|
I replaced |
…ffers This commit makes diff-hl--update identify the base buffer of the current file and iterate through all live buffers to apply diff highlighting to any indirect clones.
efd30f4 to
34cb601
Compare
|
I found a way to fix it. Try the latest commit. I updated |
|
We could optimize this by making |
When you said "the issue", did you mean that the current indirect buffer was not updated after editing and saving? Or that some other related buffers were not updated. |
|
The issue: Applying this patch ensures that |
|
I'm asking specifically about the last commit. It seems to be more in the "nice to have" category. Iterating along the whole buffer list (or managing the indirect buffers list) has a cost as well. So how about we clarify that first. |
|
I can optimize this by storing a list of indirect buffers in a local variable in the base buffer each time an indirect buffer with Please confirm that:
This way, I will not spend time on it unnecessarily. |
|
Could we get the answer to my last question first? If the last change is less critical, we could split the improvement this way:
Or something like that, I haven't decided yet. You don't need to polish the implementation further yet, but testing the alternatives and describing the results (and possible downsides) is what's valuable here. |
|
Hi Dmitry, I am currently using this implementation with many indirect buffers and it works well. This pull request can be merged as is after more testing. (The To answer your questions: the last change is not just an optional enhancement. It is required because without it, the highlighting does not work at all in indirect buffers. While my initial commits fixed the file name resolution, the margin and fringe still failed to update or display any indicators in the indirect buffer. The logic introduced in the last commit is what actually ensures the visual elements to render in the indirect buffers/clones. Splitting the improvement into a simpler change for the active buffer and a separate hook for related buffers will not resolve the issue. Just try it with and without the latest commit. You'll see the difference. |
Here is a first attempt to fix the indirect buffer issue: #272 (comment)
I replaced all instances of
buffer-file-namewith a function that supports indirect buffers:diff-hl--buffer-file-namefunction to retrieve the file name of the current buffer or its base buffer.buffer-file-namevariable with the new helper changes to all live buffers sharing the same base buffer.It successfully returns the correct file name. However, it does not fix the issue of the margin and fringe not updating. An additional change is required to fix #272 (comment) .
Let us collaborate to address the issue, given your familiarity with the
diff-hlcodebase and your ability to assist or contribute to fixing it once and for all.