Changeset 14480


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.

Location:
trunk/source/cocoa-ide/hemlock/src
Files:
2 edited

Legend:

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

    r12564 r14480  
    532532          (setq start middle))))))
    533533
     534(defun buffer-lines-before-absolute-position (buffer position)
     535  (do* ((prev (line-previous (buffer-line-at-absolute-position buffer position))
     536              (line-previous prev))
     537        (n 0))
     538       ((null prev) n)
     539    (declare (fixnum n))
     540    (incf n)))
     541
    534542;; Called whenever change a line's next or previous pointer.  Don't update immediately
    535543;; so don't thrash when inserting multiple lines.
  • 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.