Changeset 15334


Ignore:
Timestamp:
Apr 19, 2012, 9:02:08 AM (7 years ago)
Author:
gb
Message:

Fix ticket:958 (select previous/next line at beginning/end of buffer.)

File:
1 edited

Legend:

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

    r15291 r15334  
    305305(defcommand "Select Next Line" (p)
    306306  "Moves the point to the next line, extending the selection.
    307    With prefix argument, moves the point that many lines down (or up if
    308    the prefix is negative)."
    309   "Moves the down p lines, extending the selection."
    310   (let* ((p (or p 1)))
    311     (if (< p 0)
    312       (select-previous-line-command (- p))
    313       (let* ((point (current-point-for-selection-end))
    314              (target (set-target-column point)))
    315         (unless (line-offset point (or p 1))
    316           (when (value next-line-inserts-newlines)
    317             (cond ((not p)
    318                    (when (same-line-p point (buffer-end-mark (current-buffer)))
    319                      (line-end point))
    320                    (insert-character point #\newline))
    321                   (t
    322                    (buffer-end point)
    323                    (when p (editor-error "No next line."))))))
    324         (unless (move-to-position point target) (line-end point))
    325         (setf (last-command-type) :line-motion)))))
     307  With prefix argument, moves the point that many lines down (or up if
     308  the prefix is negative)."
     309  "Moves the down p lines, extending the selection."
     310  (if (and p (< p 0))
     311    (select-previous-line-command (- p))
     312    (let* ((point (current-point-for-selection-end))
     313           (target (set-target-column point))
     314           (count (or p 1))
     315           (seek-target t))
     316      (unless (line-offset point count)
     317        (cond ((and (not p) (value next-line-inserts-newlines))
     318               (when (same-line-p point (buffer-end-mark (current-buffer)))
     319                 (line-end point))
     320               (insert-character point #\newline))
     321              ((minusp count)
     322               (buffer-start point)
     323               (setq seek-target nil))
     324              (t
     325               (buffer-end point)
     326               (setq seek-target nil))))
     327      (when seek-target
     328        (unless (move-to-position point target) (line-end point)))
     329      (setf (last-command-type) :line-motion))))
    326330
    327331
     
    343347      (let* ((point (current-point-for-selection-start))
    344348             (target (set-target-column point)))
    345         (line-offset point (- p))
    346         (unless (move-to-position point target) (line-end point))
     349        (if (line-offset point (- p))
     350          (unless (move-to-position point target) (line-end point))
     351          (buffer-start point))
    347352        (setf (last-command-type) :line-motion)))))
    348353
Note: See TracChangeset for help on using the changeset viewer.