Changeset 12651


Ignore:
Timestamp:
Aug 23, 2009, 4:51:03 PM (10 years ago)
Author:
gz
Message:

In find-definition-by-context, start search at the beginning of buffer. Also, if there is only one occurance of the name in whole buffer, just go there no matter what the context.

In move-to-source-note, only use toplevel note if that has text, and then remember to move start mark if using it.

Collapse selection in move-point-leaving-mark so callers don't have to.

File:
1 edited

Legend:

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

    r12635 r12651  
    313313  (let* ((base-name (ccl::definition-base-name def-type full-name))
    314314         (string (string base-name))
    315          (pattern (new-search-pattern :string-insensitive :forward string)))
    316     (with-mark ((mark (current-point)))
    317       (when (loop
    318                while (find-pattern mark pattern)
    319                thereis (and (match-definition-context mark def-type full-name)
    320                             (backward-up-list mark))
    321                do (character-offset mark 1))
     315         (pattern (new-search-pattern :string-insensitive :forward string))
     316         (found 0))
     317    (with-mark ((mark (buffer-start-mark (current-buffer))))
     318      (when (or (loop
     319                  while (and (find-pattern mark pattern) (incf found))
     320                  thereis (and (match-definition-context mark def-type full-name)
     321                               (backward-up-list mark))
     322                  do (character-offset mark 1))
     323                ;; if there is only one instance, just go there
     324                (and (eql found 1) (find-pattern (buffer-start mark) pattern))
     325                ;; Else should try again, being less strict...
     326                )
    322327        (move-point-leaving-mark mark)))))
    323328
    324329(defun move-point-leaving-mark (target)
    325   (let ((point (current-point)))
     330  (let ((point (current-point-collapsing-selection)))
    326331    (push-new-buffer-mark point)
    327332    (move-mark point target)
     
    342347          (declare (inline search))
    343348          (with-mark ((temp-mark (current-point)))
    344             (unless (move-to-absolute-position temp-mark start-pos)
    345               (buffer-end temp-mark))
    346349            (unless full-text
    347350              ;; Someday, might only store a snippet for toplevel, so inner notes
     
    349352              (let* ((toplevel (ccl::source-note-toplevel-note source))
    350353                     (toplevel-start-pos (and (not (eq toplevel source))
    351                                               (ccl:source-note-start-pos toplevel))))
    352                 (when toplevel-start-pos
     354                                              (ccl:source-note-start-pos toplevel)))
     355                     (text (and toplevel-start-pos (ccl:source-note-text toplevel))))
     356                (when text
    353357                  (setq offset (- start-pos toplevel-start-pos))
    354358                  (setq start-pos toplevel-start-pos)
    355                   (setq full-text (ccl:source-note-text toplevel)))))
     359                  (setq full-text text)
     360                  (character-offset temp-mark (- offset)))))
     361            (unless (move-to-absolute-position temp-mark start-pos)
     362              (buffer-end temp-mark))
     363
    356364            (when (or (null full-text)
    357365                      (or (search temp-mark full-text :forward)
     
    367375
    368376(defun find-definition-in-buffer (def-type full-name source)
    369   (current-point-collapsing-selection)
    370377  (or (and (ccl:source-note-p source)
    371378           (move-to-source-note source))
Note: See TracChangeset for help on using the changeset viewer.