Changeset 212


Ignore:
Timestamp:
11/06/02 02:51:35 (21 years ago)
Author:
piso
Message:

findTag(Editor, Expression, boolean): make sure we return true if we find a match.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/j/TagCommands.java

    r208 r212  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: TagCommands.java,v 1.5 2002-11-05 17:38:09 piso Exp $
     5 * $Id: TagCommands.java,v 1.6 2002-11-06 02:51:35 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    9797        boolean useOtherWindow)
    9898    {
    99         final Buffer buffer = editor.getBuffer();
    100         boolean succeeded = false;
    101         List tags = findMatchingTags(buffer, expression);
    102         if (tags != null) {
    103             if (tags.size() > 1) {
    104                 editor.setDefaultCursor();
    105                 ListTagsBuffer buf =
    106                     new ListTagsBuffer(editor, "findTag", expression.getName(), tags);
    107                 editor.makeNext(buf);
    108                 Editor ed = editor.activateInOtherWindow(buf);
    109                 ed.setDot(buf.getInitialDotPos());
    110                 ed.moveCaretToDotCol();
    111                 ed.updateDisplay();
    112             } else if (tags.size() == 1) {
    113                 // Exactly one match.
    114                 Tag tag = (Tag) tags.get(0);
    115                 editor.pushPosition();
    116                 if (tag instanceof LocalTag) {
    117                     gotoLocalTag(editor, (LocalTag)tag, useOtherWindow);
    118                     succeeded = true;
    119                 } else if (tag instanceof GlobalTag) {
    120                     gotoGlobalTag(editor, (GlobalTag)tag, useOtherWindow);
    121                     succeeded = true;
    122                 } else
    123                     Debug.bug();
    124             }
    125         }
    126         return succeeded;
     99        List tags = findMatchingTags(editor.getBuffer(), expression);
     100        if (tags == null || tags.size() == 0)
     101            return false;
     102        if (tags.size() == 1) {
     103            // One match.
     104            Tag tag = (Tag) tags.get(0);
     105            editor.pushPosition();
     106            if (tag instanceof LocalTag)
     107                gotoLocalTag(editor, (LocalTag)tag, useOtherWindow);
     108            else if (tag instanceof GlobalTag)
     109                gotoGlobalTag(editor, (GlobalTag)tag, useOtherWindow);
     110            else
     111                Debug.bug();
     112        } else {
     113            // More than one match.
     114            editor.setDefaultCursor();
     115            ListTagsBuffer buf =
     116                new ListTagsBuffer(editor, "findTag", expression.getName(), tags);
     117            editor.makeNext(buf);
     118            Editor ed = editor.activateInOtherWindow(buf);
     119            ed.setDot(buf.getInitialDotPos());
     120            ed.moveCaretToDotCol();
     121            ed.updateDisplay();
     122        }
     123        return true;
    127124    }
    128125
Note: See TracChangeset for help on using the changeset viewer.