From: <dal...@us...> - 2010-05-24 16:59:13
|
Revision: 17878 http://jedit.svn.sourceforge.net/jedit/?rev=17878&view=rev Author: daleanson Date: 2010-05-24 16:59:07 +0000 (Mon, 24 May 2010) Log Message: ----------- Made some changes suggested by Kazutoshi. Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/ModeProvider.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/ModeProvider.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/ModeProvider.java 2010-05-24 14:07:37 UTC (rev 17877) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/ModeProvider.java 2010-05-24 16:59:07 UTC (rev 17878) @@ -35,6 +35,7 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.LinkedHashMap; //}}} @@ -60,6 +61,7 @@ public void removeAll() { modes.clear(); + overrideModes.clear(); } //}}} //{{{ getMode() method @@ -70,7 +72,12 @@ */ public Mode getMode(String name) { - return modes.get(name); + Mode mode = overrideModes.get(name); + if (mode == null) + { + mode = modes.get(name); + } + return mode; } //}}} //{{{ getModeForFile() method @@ -112,7 +119,10 @@ { return acceptable.get(0); } - if (acceptable.size() > 1) { + if (acceptable.size() > 1) + { + Collections.reverse(acceptable); + // most acceptable is a mode that matches both the // filename and the first line glob for (Mode mode : acceptable) @@ -146,8 +156,11 @@ */ public Mode[] getModes() { - Mode[] array = new Mode[modes.size()]; - modes.values().toArray(array); + Mode[] array = new Mode[modes.size() + overrideModes.size()]; + Mode[] standard = modes.values().toArray(new Mode[0]); + Mode[] override = overrideModes.values().toArray(new Mode[0]); + System.arraycopy(standard, 0, array, 0, standard.length); + System.arraycopy(override, 0, array, standard.length, override.length); return array; } //}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |