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

Update semantic highlighting code in line with the update IDE protocol #11

Merged
merged 2 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions idris2-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ A prefix argument forces loading but only up to the current line."
(when (string= (file-name-nondirectory fn)
(file-name-nondirectory (buffer-file-name)))
(idris2-highlight-input-region (current-buffer)
start-line start-col
end-line end-col
(+ 1 start-line) (+ 1 start-col)
(+ 1 end-line ) (+ 1 end-col)
props))))))
(_ (idris2-make-clean)
(idris2-update-options-cache)
Expand Down Expand Up @@ -364,14 +364,16 @@ compiler-annotated output. Does not return a line number."

(defun idris2-jump-to-location (loc is-same-window)
"jumps to specified location"
(pcase-let* ((`(,name ,file ,line ,col) loc)
(pcase-let* ((`(,name (:filename ,file)
(:start ,line ,col)
(:end ,_ ,_)) loc)
(full-path file))
(xref-push-marker-stack) ;; this pushes a "tag" mark. haskell mode
;; also does this and it seems appropriate, allows the user to pop
;; the tag and go back to the previous point. (pop-tag-mark
;; default Ctl-t)
(if full-path
(idris2-goto-source-location-full full-path (+ 1 line) col is-same-window)
(idris2-goto-source-location-full full-path (+ 1 line) (+ col 1) is-same-window)
(user-error "Source not found for %s" file)
)
)
Expand All @@ -386,7 +388,7 @@ compiler-annotated output. Does not return a line number."
(let ((inhibit-read-only t))
(erase-buffer)
(dolist (loc (reverse locs))
(pcase-let* ((`(,name ,file ,line ,col) loc)
(pcase-let* ((`(,name (:filename ,file) ,_ ,_) loc)
(fullpath file)
)
(if (file-exists-p fullpath)
Expand Down
4 changes: 2 additions & 2 deletions idris2-highlight-input.el
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ See Info node `(elisp)Overlay Properties' to understand how ARGS are used."
(widen)
(if (or (> end-line start-line)
(and (= end-line start-line)
(>= end-col start-col)))
(> end-col start-col)))
(with-current-buffer buffer
(save-excursion
(goto-char (point-min))
(let* ((start-pos (+ (line-beginning-position start-line)
(idris2-highlight-column start-col)))
(end-pos (+ (line-beginning-position end-line)
(idris2-highlight-column (+ 1 end-col))))
(idris2-highlight-column end-col)))
(highlight-overlay (make-overlay start-pos end-pos
(get-buffer buffer))))
(overlay-put highlight-overlay 'idris2-source-highlight t)
Expand Down
6 changes: 3 additions & 3 deletions idris2-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ Invokes `idris2-repl-mode-hook'."
(input-col (save-excursion
(goto-char start-pos)
(current-column)))
(start-line-repl (+ input-line start-line -1))
(start-col-repl (+ input-col start-col))
(end-line-repl (+ input-line end-line -1))
(start-line-repl (+ input-line start-line -1)) ;; Revisit these once we implement
(start-col-repl (+ input-col start-col)) ;; highlighting of repl inputs
(end-line-repl (+ input-line end-line -1)) ;; in case bounds need to be adjusted
(end-col-repl (+ input-col end-col)))
(idris2-highlight-input-region buffer
start-line-repl start-col-repl
Expand Down