Ignore:
Timestamp:
Dec 11, 2010, 3:52:40 AM (9 years ago)
Author:
gb
Message:

Compensate for CRLF line-termination in meta-.
Fixes ticket:741, but note that there may be other problems
with (e.g.) variable-length character encodings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/hemlock/src/edit-defs.lisp

    r13427 r14480  
    324324    point))
    325325
     326;;; Adjust for CRLF line termination.  Multibyte character encodings
     327;;; can also cause discrepancies between physical/logical positions.
     328;;; Handling that would require making the source location stuff
     329;;; aware of that newfangled Unicode thing ...
     330(defun byte-position-to-character-position (pos &optional (buffer (current-buffer)))
     331  (let* ((line-termination (hi::buffer-line-termination buffer)))
     332    (if (eq line-termination :crlf)
     333      (- pos (hi::buffer-lines-before-absolute-position buffer pos))
     334      pos)))
     335
    326336(defun move-to-source-note (source)
    327337  (let ((start-pos (ccl:source-note-start-pos source)))
    328338    (when start-pos
     339      (setq start-pos (byte-position-to-character-position start-pos))
    329340      (let ((full-text (ccl:source-note-text source))
    330341            (pattern nil)
     
    346357                     (text (and toplevel-start-pos (ccl:source-note-text toplevel))))
    347358                (when text
     359                  (setq toplevel-start-pos (byte-position-to-character-position toplevel-start-pos))
    348360                  (setq offset (- start-pos toplevel-start-pos))
    349361                  (setq start-pos toplevel-start-pos)
Note: See TracChangeset for help on using the changeset viewer.