Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Buffer Relative Placement #27

Closed
wants to merge 1 commit into from

Conversation

benlubas
Copy link
Contributor

current behavior

We can set buffer on an image, the same as window. When window is set (alone or with
buffer), the image is positioned relative to the window. If just buffer is set (alone) then the
image is positioned absolutely on the screen.

after this PR

if buffer is set and window is not, try to find a window that houses the buffer, set window
and continue to render now with both window and buffer set.

things to consider

  • This is a potentially breaking change if anything is relying on the old behavior.
  • Two windows showing the same buffer is still not supported (although I think this is true of the
    entire plugin)
  • Should we actually set the window on the image? or use something temporary for the single render
    cycle?

That last question concern is the big one for me. I'm not sure what makes the most sense here

@3rd
Copy link
Owner

3rd commented Sep 25, 2023

Hey, I think we need to keep the requirement that both windows and buffers are set for the automatic handling logic to kick in.

There is support for having the same buffer in two windows and rendering the images separately, there's just some issues around extmark compensation, which happen when something containing an image is folded in a window and it isn't in another. (I don't think we can fix that unless there's going to be some kind of way to add per-window-buffer-pair extmarks.)

image-split.mp4

The window/buffer placement is very easy to think about, and makes this "mount to this position when buffer is in window x" helper logic easy to integrate for the most common document-related use cases, and it comes at no expense for the caller, always passing the window isn't hard.

@3rd
Copy link
Owner

3rd commented Sep 25, 2023

If you use a floating window for dccsillag/magma-nvim#115 it should work great if you pass the window & buffer id.

@benlubas
Copy link
Contributor Author

Magma constructs its output buffer (including images), before the floating window is created. I think the reason was to make the output window exactly as tall as it needs to be.

I can just update image's window after the fact I guess

@3rd
Copy link
Owner

3rd commented Sep 25, 2023

Magma constructs its output buffer (including images), before the floating window is created. I think the reason was to make the output window exactly as tall as it needs to be.

I can just update image's window after the fact I guess

You can create the image without rendering it, the width/height should be available.

@benlubas benlubas closed this Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants