Revision: 6534
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=6534&view=rev
Author:   dnaber
Date:     2012-02-19 14:17:50 +0000 (Sun, 19 Feb 2012)
Log Message:
-----------
consecutive tab characters are not considered an error anymore

Modified Paths:
--------------
    trunk/JLanguageTool/CHANGES.txt
    trunk/JLanguageTool/src/java/org/languagetool/rules/WhitespaceRule.java
    trunk/JLanguageTool/src/test/org/languagetool/rules/WhitespaceRuleTest.java

Modified: trunk/JLanguageTool/CHANGES.txt
===================================================================
--- trunk/JLanguageTool/CHANGES.txt     2012-02-19 13:00:33 UTC (rev 6533)
+++ trunk/JLanguageTool/CHANGES.txt     2012-02-19 14:17:50 UTC (rev 6534)
@@ -25,6 +25,7 @@
  -bugfix: the "fromx" position in the XML output was wrong sometimes
  -bugfix: the "contextoffset" position in the XML output was wrong
   when there were XML-escaped characters in the context
+ -consecutive tab characters are not considered an error anymore
 
  -GUI: errors are now marked with red background instead of red font
   so whitespace problems can easily be spotted

Modified: 
trunk/JLanguageTool/src/java/org/languagetool/rules/WhitespaceRule.java
===================================================================
--- trunk/JLanguageTool/src/java/org/languagetool/rules/WhitespaceRule.java     
2012-02-19 13:00:33 UTC (rev 6533)
+++ trunk/JLanguageTool/src/java/org/languagetool/rules/WhitespaceRule.java     
2012-02-19 14:17:50 UTC (rev 6534)
@@ -62,14 +62,16 @@
     //token no. 0 is guaranteed to be SENT_START
     int i = 1;
     while (i < tokens.length) {
-      if (tokens[i].isWhitespace() && prevWhite && !tokens[i 
-1].isLinebreak()) {
+      final boolean tokenIsTab = tokens[i].getToken().equals("\t");
+      final boolean prevTokenIsLinebreak = tokens[i -1].isLinebreak();
+      if (tokens[i].isWhitespace() && prevWhite && !tokenIsTab && 
!prevTokenIsLinebreak) {
         final int pos = tokens[i -1].getStartPos();
         while (i < tokens.length && tokens[i].isWhitespace()) {
           prevLen += tokens[i].getToken().length();
           i++;
         }
-        final RuleMatch ruleMatch = new RuleMatch(this, prevPos, pos + 
prevLen, messages
-            .getString("whitespace_repetition"));
+        final String message = messages.getString("whitespace_repetition");
+        final RuleMatch ruleMatch = new RuleMatch(this, prevPos, pos + 
prevLen, message);
         ruleMatch.setSuggestedReplacement(" ");
         ruleMatches.add(ruleMatch);
       }

Modified: 
trunk/JLanguageTool/src/test/org/languagetool/rules/WhitespaceRuleTest.java
===================================================================
--- trunk/JLanguageTool/src/test/org/languagetool/rules/WhitespaceRuleTest.java 
2012-02-19 13:00:33 UTC (rev 6533)
+++ trunk/JLanguageTool/src/test/org/languagetool/rules/WhitespaceRuleTest.java 
2012-02-19 14:17:50 UTC (rev 6534)
@@ -43,7 +43,9 @@
       assertEquals(0, matches.length);
       matches = rule.match(langTool.getAnalyzedSentence("\n\tThis is a test 
sentence..."));
       assertEquals(0, matches.length);
-      
+      matches = rule.match(langTool.getAnalyzedSentence("Multiple tabs\t\tare 
okay"));
+      assertEquals(0, matches.length);
+
       // incorrect sentences:
       matches = rule.match(langTool.getAnalyzedSentence("This  is a test 
sentence."));
       assertEquals(1, matches.length);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to