Skip to content

Conversation

@tbung
Copy link
Contributor

@tbung tbung commented Jan 31, 2022

This PR adds a new function to handle CursorMoved and WinScrolled. On CursorMoved it only rehighlights when the cursor left the cell, WinScrolled only redraws the output if the end of the cell is in the visible range of the window.

This closes #40 .

selected_cell = self._get_selected_span()

if self.selected_cell == selected_cell and selected_cell is not None:
if selected_cell.end.lineno < self.nvim.funcs.line("w$") and self.should_open_display_window and scrolled:
Copy link
Owner

@dccsillag dccsillag Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the purpose of this conditional, and it doesn't seem right to me.

self.nvim.funcs.line("w$") will give the line number of the last visible line in the window (note: this is a Vim API and line numbers are different in neovim APIs; that's why it's < and not <=, I imagine). But what if part of the cell is visible but its end is past the end of the buffer?

Furthermore, why is this done:

                if self.display_window is not None: # and self.nvim.funcs.winbufnr(self.display_window) != -1:
                    self.nvim.funcs.nvim_win_close(self.display_window, True)
                    self.canvas.clear()
                    self.display_window = None
                self._show_outputs(self.outputs[selected_cell], selected_cell.end)
                self.canvas.present()

instead of just

self.clear_interface()
self._show_outputs(self.outputs[selected_cell], selected_cell.end)
self.canvas.present()

?

@benlubas benlubas mentioned this pull request Sep 25, 2023
6 tasks
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.

[Feature Request] Performance improvements

2 participants