Changeset 1131


Ignore:
Timestamp:
Jun 30, 2011, 9:00:45 PM (6 years ago)
Author:
stefan
Message:

enhanced auto closing of environment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/codehelper/LatexLineBreakListener.java

    r1130 r1131  
    3535      Iterator<WordWithPos> openEnvIterator = EnvironmentUtils.getOpenEnvIterator(pane);
    3636      if (openEnvIterator.hasNext()) {
    37         WordWithPos env = openEnvIterator.next();
    38         if (env.getStartRow() == row - 1) {
     37        WordWithPos openEnvWord = openEnvIterator.next();
     38        if (openEnvWord.getStartRow() == row - 1) {
    3939          indent   = GProperties.getBoolean("editor.auto_indentation.after_begin");
    4040          closeEnv = GProperties.getBoolean("editor.auto_close_environment");
    41           envName  = env.word;
     41          envName  = openEnvWord.word;
     42
     43          if (closeEnv) {
     44            // do not close env if it is already closed
     45            Iterator<WordWithPos> closeEnvIterator = EnvironmentUtils.getCloseEnvIterator(pane);
     46            if (closeEnvIterator.hasNext()) {
     47              WordWithPos closeEnvWord = closeEnvIterator.next();
     48              if (closeEnvWord.word.equals(envName)) {
     49                closeEnv = closeEnvWord.getStartCol() != openEnvWord.getStartCol() - 2;
     50              }
     51            }
     52          }
    4253        }
    4354      }
Note: See TracChangeset for help on using the changeset viewer.