mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 23:41:38 -05:00
Handle the invisible characters in the REPL buffer when extracting code context
This commit is contained in:
parent
65dc7796ed
commit
b06a586831
1 changed files with 9 additions and 11 deletions
|
@ -1643,22 +1643,20 @@ if TYPE is `inspect'."
|
|||
(cl-case type
|
||||
(inspect
|
||||
(setq code
|
||||
;; TODO: This still needs work
|
||||
(save-excursion
|
||||
;; Ignore the invisible characters of a prompt
|
||||
(when (and (eq major-mode 'jupyter-repl-mode)
|
||||
(field-at-pos (point)))
|
||||
(goto-char (1+ (field-end))))
|
||||
(buffer-substring
|
||||
(line-beginning-position)
|
||||
(line-end-position)))
|
||||
(buffer-substring
|
||||
(if (and (eq major-mode 'jupyter-repl-mode)
|
||||
(invisible-p (line-beginning-position)))
|
||||
(next-single-property-change
|
||||
(line-beginning-position) 'invisible)
|
||||
(line-beginning-position))
|
||||
(line-end-position))
|
||||
;; NOTE: The +1 is because normally, when inspecting code, `point'
|
||||
;; is on a character of the symbol being inspected, this is in
|
||||
;; contrast to completing code where `point' is after the last
|
||||
;; character of the prefix. This fixes an edge case where `point'
|
||||
;; is at the first character of a symbol.
|
||||
pos (1+ (- (point) (line-beginning-position)))))
|
||||
(complete
|
||||
pos (- (point) (line-beginning-position))))
|
||||
(completion
|
||||
(if (eq major-mode 'jupyter-repl-mode)
|
||||
(setq code (jupyter-repl-cell-code)
|
||||
pos (1- (jupyter-repl-cell-code-position)))
|
||||
|
|
Loading…
Add table
Reference in a new issue