jupyter-org--set-current-src-block: Simplify calculation of block end

This also fixes an edge case when there is only one blank line after the source
block. The previous version would consider the beginning of the last line of
the code block as the end instead of the beginning of the `#+end_src` line in
that case.
This commit is contained in:
Nathaniel Nicandro 2019-03-31 10:34:00 -05:00
parent 460eba73ec
commit 80c623ab40
No known key found for this signature in database
GPG key ID: C34814B309DD06B8

View file

@ -355,15 +355,12 @@ most recent completion request.")
(let* ((info (org-babel-get-src-block-info el))
(params (nth 2 info))
(beg (save-excursion
(goto-char
(org-element-property :post-affiliated el))
(goto-char (org-element-property :post-affiliated el))
(line-beginning-position 2)))
(end (save-excursion
(goto-char
(org-element-property :end el))
(let ((pblank (org-element-property :post-blank el)))
(line-beginning-position
(unless (zerop pblank) (- pblank)))))))
(goto-char (org-element-property :end el))
(skip-chars-backward "\r\n")
(line-beginning-position))))
(unless jupyter-org--src-block-cache
(setq jupyter-org--src-block-cache
(list nil (point-marker) (point-marker)))