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

What exactly is evaluated and invalidated #39

Closed
ArbitRandomUser opened this issue Sep 11, 2024 · 14 comments
Closed

What exactly is evaluated and invalidated #39

ArbitRandomUser opened this issue Sep 11, 2024 · 14 comments

Comments

@ArbitRandomUser
Copy link
Contributor

a=1
b=2
c=3

now when i edit them as such ...

I change 3rd line by adding a space after it , it gets invalidated.
but if i change second line after that it does not get invalidated.

other changes introduce some invalidations in other nearby lines and its a little confusing as to what the marks exactly mean

@ArbitRandomUser
Copy link
Contributor Author

ArbitRandomUser commented Sep 11, 2024

also could there a way to disable this altogether ?
maybe the sign mark can be an config option and setting it to "" would disable the signs altogether

@Klafyvel
Copy link
Owner

It is supposed to track when an evaluated code block has been modified since evaluation. The thing is it uses the [ and ] marks, which are a bit tricky sometimes. It seems it broke between the time I implemented it and when I merded the PR. It should be fairly easy to add an configuration option to disable that.

@ArbitRandomUser
Copy link
Contributor Author

do you remember a commit where it would have been working right ?

@Klafyvel
Copy link
Owner

For sure it worked when I wrote that comment: #15 (comment) since there's a video, I believe it worked here as well: #15 (comment) .

@Klafyvel
Copy link
Owner

If you want to debug that, I'd advise setting the log level to "debug", that way the evaluated chunks will have a clear unmistakable highlight (they get the TermCursor highlight group).

@ArbitRandomUser
Copy link
Contributor Author

it seems the marks are updated only after a shift to normal mode from insert mode

was just playing around with the following autocmd enabled

autocmd TextChangedI * :lua vim.print({"beg",vim.api.nvim_buf_get_mark(0,"["),"end",vim.api.nvim_buf_get_mark(0,"]")})

@ArbitRandomUser
Copy link
Contributor Author

is it intended that chunk invalidation gets called at every keystroke

@Klafyvel
Copy link
Owner

Yes, it was intended. Wether this is wise is another question.

@ArbitRandomUser
Copy link
Contributor Author

i'm having a little trouble wrapping my head around how its structured.

invalidate_changed_chunks is invoked only when update_chunk_display_event is set.

the event buffer.update_chunk_display_event is set only inside delete_interesected_chunks which is called only inside reslime functions .
i.e when either Smuggle or SmuggleVisual etc are called.

so how does it end up being called every keystroke ?

@ArbitRandomUser
Copy link
Contributor Author

*every keystroke in insert mode

@ArbitRandomUser
Copy link
Contributor Author

okay nvm it just occured to me to look for an autocmd when i was done typing this

@ArbitRandomUser
Copy link
Contributor Author

okay not exactly a solution , but a compromise would be to have set the event at InsertLeave over here ?

function ui.init_buffer(bufnbr)
vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI" }, {
callback = function(args)
run.buffers[bufnbr].update_chunk_display_event.set()

@ArbitRandomUser
Copy link
Contributor Author

okay i thought it worked but nope , that still does the wrong thing

@ArbitRandomUser
Copy link
Contributor Author

okay here is something that works

instead of finding entire chunks, if we treat every keystroke as a "single character chunk" find intersections and invalidate them.

#43

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

No branches or pull requests

2 participants