Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Wrong :beg and :end for source files with CRLF line endings #211
IProblem apparently reports the begin and and ending of a problem in regard to the byte (character) offset in binary mode.
But Emacs basically strips the CR characters from the file when displaying it in a buffer, so the start and end pointers are
Looking into it, I see that you've already tried to fix the position in ensime-make-overlay-at by recalculating beg and end using (the erroneous) positions... Alas, this doesn't work.
Why not pass the
(defun ensime-make-overlay-at (file line b e msg face) "Create an overlay highlighting the given line in any buffer visiting the given file." (let ((beg b) (end e)) (assert (or (integerp line) (and (integerp beg) (integerp end)))) (when-let (buf (find-buffer-visiting file)) (with-current-buffer buf (if (and (integerp beg) (integerp end)) ;; If DOS eol's, fix the positioning ;; Note: this is impossible without the line argument. (when (and (integerp line) (eq 1 (coding-system-eol-type (buffer-local-value 'buffer-file-coding-system buf)))) (setq beg (- beg (1- line))) (setq end (- end (1- line)))) ;; If line provided, use line to define region (save-excursion (goto-line line) (setq beg (point-at-bol)) (setq end (point-at-eol))))) (ensime-make-overlay beg end msg face nil buf)) )) (defun ensime-make-note-overlays (notes) (dolist (note notes) (destructuring-bind (&key severity msg beg end line col file &allow-other-keys) note ;; No empty note overlays! (when (eq beg end) (setq beg (- beg 1))) (let ((lang (cond ((ensime-java-file-p file) 'java) ((ensime-scala-file-p file) 'scala) (t 'scala))) (face (cond ((equal severity 'error) 'ensime-errline-highlight) (t 'ensime-warnline-highlight)))) (when-let (ov (ensime-make-overlay-at file line (+ beg ensime-ch-fix) (+ end ensime-ch-fix) msg face)) (overlay-put ov 'lang lang) (push ov ensime-note-overlays)) ))))
edit: The problem also occurs the other way round: when using e.g. ensime-refactor-rename the transmitted character positions are in emacs' point system and probably would need to be translated...
pushed a commit
Dec 10, 2012
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
As this fix has been lying around for at least a year now, i took the changes and put them into a commit. @tstgruby i mentioned you in the commit message, as i could not figure out how to set the author field to a name that did not yet show up in the history. I hope this is ok with you.
PS: I am sorry for the two mentions from two different commits with the same content, i did not realise the first one would still exist. If anyone has a tip on how to remove this, i would be very happy to hear it.