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

define message methods for SharedBuffer instead of Buffer #3588

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matthias314
Copy link
Contributor

AddMessage and the like are defined for Buffer although they only use the SharedBuffer part. This PR defines them for SharedBuffer. As a consequence, these methods can now be used from within the onBeforeTextEvent callback, which receives a SharedBuffer as argument.

@usfbih8u
Copy link
Contributor

As a consequence, these methods can now be used from within the onBeforeTextEvent callback, which receives a SharedBuffer as argument

With this PR, how a plugin can differentiate between a text event in the buffer and a message added?

@matthias314
Copy link
Contributor Author

matthias314 commented Feb 26, 2025

What exactly do you mean? Everything that a plugin could do without this PR is still possible with it.

OK, now I believe I know what you mean. The idea is that text events can trigger messages. For example, the bookmark plugin uses messages to define bookmarks. Currently, it needs a lot of code to adjust the position of those bookmarks when text is added or deleted. With onBeforeTextEvent, this becomes much simpler in my opinion. See the proof of concept here.

@usfbih8u
Copy link
Contributor

I misread your first message.

What I was asking was whether adding a Message, etc., now triggers the onBeforeTextEvent() callback.

Now I see that what you are doing is checking if the text events are affecting your bookmarks (by moving them through removing/inserting lines, etc.).

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