Skip to content

Conversation

@Antonio-R1
Copy link

@Antonio-R1 Antonio-R1 commented Nov 13, 2022

Added support for syncing the scroll position of the webview with the position of the cursor.

I also tried to create a python3-markdown plugin as described in my comment in issue #35, but I could only find a hack solution. For lists and code blocks, for example, it only outputs the source line of the beginning of the list or code block, respectively.

The sourcepos extension from pandoc is only available for the commonmark, commonmark_x and gfm formats. This pull request changes the input format to commonmark and for using features like tables etc., the required extensions needs to be enabled or one of the other two formats can be used.

Currently, the position is always synced when the document is reloaded, but I think a new option in the preference window can be added for activating or deactivating the synchronization of the scroll position.

Copy link
Owner

@maoschanz maoschanz left a comment

Choose a reason for hiding this comment

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

it's pretty hard to read and without comments, so i needed a lot of motivation to review it sorry

}
}
if (highestLowerBoundElement) {
highestLowerBoundElement.scrollIntoViewIfNeeded();
Copy link
Owner

Choose a reason for hiding this comment

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

why "if needed"? isn't the standard just "scrollIntoView"?


_ = init_gettext()

SCRIPT_SCROLL_TO_CURSOR = """
Copy link
Owner

Choose a reason for hiding this comment

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

the script could be in a separate file, and loaded in the init. This way, it could be a js file with syntax coloration

unsaved_text = doc.get_text(start, end, True)
cursor_position = doc.get_property("cursor-position")
text_iter = doc.get_iter_at_offset(cursor_position)
self._webview_manager.set_cursor_position (text_iter.get_line()+1, text_iter.get_line_offset()+1)
Copy link
Owner

Choose a reason for hiding this comment

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

why "+1"? does it not understand zeros? then isn't it problematic that you set cursor_row and column as 0 in the init?

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