diff --git a/autotests/folding/Makefile.fold b/autotests/folding/Makefile.fold --- a/autotests/folding/Makefile.fold +++ b/autotests/folding/Makefile.fold @@ -12,9 +12,9 @@ ifeq ($(CC),gcc) bla=$(call func,param1,param2) -else ifeq "x" "y"else ifeq "x" "y" +else ifeq "x" "y" $(error this seems wrong) -elseelse +else libs=$(normal_libs) endif diff --git a/autotests/folding/folding.cpp.fold b/autotests/folding/folding.cpp.fold --- a/autotests/folding/folding.cpp.fold +++ b/autotests/folding/folding.cpp.fold @@ -10,6 +10,6 @@ } #if 0 -#elif 1#elif 1 -#else#else +#elif 1 +#else #endif diff --git a/autotests/folding/highlight.asp.fold b/autotests/folding/highlight.asp.fold --- a/autotests/folding/highlight.asp.fold +++ b/autotests/folding/highlight.asp.fold @@ -48,7 +48,7 @@ if ( variable = true ) response.end - else %>else %> + else %>

We are writing text.

<%=newVar%>

diff --git a/autotests/folding/highlight.cpp.fold b/autotests/folding/highlight.cpp.fold --- a/autotests/folding/highlight.cpp.fold +++ b/autotests/folding/highlight.cpp.fold @@ -51,17 +51,17 @@ # define A /* multi line with comment */ 23 -#else // xelse // x +#else // x #42 // gcc extension = #line 42 // error #wrong # wrong #endif x #if DS() -#else xelse x -#else /* */xelse /* */x -#else /* xelse /* x +#else x +#else /* */x +#else /* x y */ z #endif @@ -154,73 +154,73 @@ #if 1 double foo(const A); -#else // else#else // else +#else // else double foo(const A); #endif // end #if 0 double foo(const A); -#else // else#else // else +#else // else double foo(const A); #endif // end #if 1 double foo(const A); -#elif 1#elif 1 +#elif 1 double foo(const A); #elif 0 double foo(const A); #endif // end #if 0 double foo(const A); -#elif 1#elif 1 +#elif 1 double foo(const A); -#elif 0#elif 0 +#elif 0 double foo(const A); #endif // end #if 0 double foo(const A); -#elif a#elif a +#elif a double foo(const A); #elif 0 double foo(const A); -#elif a#elif a +#elif a double foo(const A); -#else // elseelse // else +#else // else double foo(const A); #endif // end #if 0 // blah blah double foo(const A); -#elif 1 // blah blah#elif 1 // blah blah +#elif 1 // blah blah double foo(const A); -#else // else#else // else +#else // else double foo(const A); #endif // end #if 0 || a double foo(const A); -#else // elseelse // else +#else // else double foo(const A); #endif // end #if 1 || a double foo(const A); -#else // else#else // else +#else // else double foo(const A); #endif // end #if 0 && a double foo(const A); -#else // elseelse // else +#else // else double foo(const A); #endif // end #if 1 && a double foo(const A); -#else // elseelse // else +#else // else double foo(const A); #endif // end @@ -246,7 +246,7 @@ { # if 0 double foo(); -# else // else# else // else +# else // else double foo(); # endif // end } @@ -257,7 +257,7 @@ #if xxx double foo(); -#elseelse +#else double foo(); #endif // end diff --git a/autotests/folding/highlight.f90.fold b/autotests/folding/highlight.f90.fold --- a/autotests/folding/highlight.f90.fold +++ b/autotests/folding/highlight.f90.fold @@ -111,7 +111,7 @@ integer, intent(in) :: i if ( i <= 1 ) then rs = 1 - elseelse + else rs = i * factorial(i - 1) end if end function factorial diff --git a/autotests/folding/highlight.lex.fold b/autotests/folding/highlight.lex.fold --- a/autotests/folding/highlight.lex.fold +++ b/autotests/folding/highlight.lex.fold @@ -18,7 +18,7 @@ DIGIT [0-9] LETTER [_a-zA-Z] -%%%% +%% /* Comment *shall be indented here* */ [ \t\n\r]+ @@ -70,7 +70,7 @@ /* Dot (match all) */ . {return yylval.int_val = yytext[0];} -%%%% +%% // Here is pure C(++) #include diff --git a/autotests/folding/highlight.pl.fold b/autotests/folding/highlight.pl.fold --- a/autotests/folding/highlight.pl.fold +++ b/autotests/folding/highlight.pl.fold @@ -6,9 +6,9 @@ { my $var = shift; - $var =~ s/bla/foo/igs;/foo/igs; - $var =~ s!bla!foo!igs;!foo!igs; - $var =~ s#bla#foo#igs;#foo#igs; + $var =~ s/bla/foo/igs; + $var =~ s!bla!foo!igs; + $var =~ s#bla#foo#igs; $var =~ tr/a-z/A-Z/; ($match) = ($var =~ m/(.*?)/igs); diff --git a/autotests/folding/highlight.pony.fold b/autotests/folding/highlight.pony.fold --- a/autotests/folding/highlight.pony.fold +++ b/autotests/folding/highlight.pony.fold @@ -140,7 +140,7 @@ try s(0) = s(0) + i s(0) - elseelse + else 0 end } diff --git a/autotests/folding/highlight.prg.fold b/autotests/folding/highlight.prg.fold --- a/autotests/folding/highlight.prg.fold +++ b/autotests/folding/highlight.prg.fold @@ -22,7 +22,7 @@ if empty(formName) ?? "Usage: ./form_ui &\n" CANCEL - elseelse + else fileName := formName endif ws := UIWorkSpace() diff --git a/autotests/folding/highlight.rb.fold b/autotests/folding/highlight.rb.fold --- a/autotests/folding/highlight.rb.fold +++ b/autotests/folding/highlight.rb.fold @@ -12,7 +12,7 @@ string.gsub(/<\/?(?:#{elements.join("|")})(?!\w)(?:.|\n)*?>/ni) do CGI::escapeHTML($&) end - elseelse + else string end end @@ -25,7 +25,7 @@ dumpVariable($1) when "quit", "exit" exit - elseelse + else print "Illegal command: #{inputLine}" end @@ -36,7 +36,7 @@ when 1910..1929 then "New Orleans Jazz" when 1930..1939 then "Swing" when 1940..1950 then "Bebop" - else "Jazz"else "Jazz" + else "Jazz" end # URL-encode a string. @@ -69,30 +69,30 @@ handle = if aSong.artist == "Gillespie" then #hi there "Dizzy" - elsif aSong.artist == "Parker" thenelsif aSong.artist == "Parker" then + elsif aSong.artist == "Parker" then "Bird" - else #hi thereelse #hi there + else #hi there "unknown" end if aSong.artist == "Gillespie" then handle = "Dizzy" -elsif aSong.artist == "Parker" then handle = "Bird"elsif aSong.artist == "Parker" then handle = "Bird" -else handle = "unknown"else handle = "unknown" +elsif aSong.artist == "Parker" then handle = "Bird" +else handle = "unknown" end #hi there if aSong.artist == "Gillespie" then handle = "Dizzy" -elsif aSong.artist == "Parker" thenelsif aSong.artist == "Parker" then +elsif aSong.artist == "Parker" then handle = "Bird" -elseelse +else handle = "unknown" end if aSong.artist == "Gillespie" handle = "Dizzy" -elsif aSong.artist == "Parker"elsif aSong.artist == "Parker" +elsif aSong.artist == "Parker" handle = "Bird" -elseelse +else handle = "unknown" end @@ -112,7 +112,7 @@ # ... when Triangle # ... - elseelse + else # ... end @@ -195,7 +195,7 @@ def system_call # ... code which throws SystemCallError -rescue SystemCallErrorrescue SystemCallError +rescue SystemCallError $stderr.print "IO failed: " + $! opFile.close File.delete(opName) @@ -225,7 +225,7 @@ @sqlQuery.selectClient.each do |row| @clients.addClient(row[0],row[1],row[2],row[3],row[4],row[5], row[6], row[7], row[8]) end - elseelse + else puts "SqlQuery wasn't created : cannot read data from database" end return @clients.length @@ -238,7 +238,7 @@ id = "0" unless @sqlQuery.nil? then id = @sqlQuery.insertClient(raison_sociale, division, departement, adresse, cp, ville, nom_contact,tel_contact) - elseelse + else puts "SqlQuery wasn't created : database update cannot be performed" end @clients.addClient(id, raison_sociale, division, departement, adresse, cp, ville, nom_contact, tel_contact) # synchronize local object with DB @@ -263,7 +263,7 @@ @sqlQuery.deleteContracts(Config::PRODUIT,listeContratsProd) @sqlQuery.deletePropositions(Config::EXPERTISE,listePropositionsExp) @sqlQuery.deletePropositions(Config::SUPPORT,listePropositionsSup) - elseelse + else puts "SqlQuery wasn't created : database update cannot be performed" end @clients.delClient(raison_sociale,div,dep) @@ -331,9 +331,9 @@ str = if arg.is_a?(Exception) "#{arg.class}: #{arg.message}\n\t" << arg.backtrace.join("\n\t") << "\n" - elsif arg.respond_to?(:to_str)elsif arg.respond_to?(:to_str) + elsif arg.respond_to?(:to_str) arg.to_str - elseelse + else arg.inspect end end @@ -508,7 +508,7 @@ send_time_data(data) when Symbol send_symbol_data(data) - elseelse + else data.send_data(self) end end diff --git a/autotests/folding/highlight.spec.fold b/autotests/folding/highlight.spec.fold --- a/autotests/folding/highlight.spec.fold +++ b/autotests/folding/highlight.spec.fold @@ -52,7 +52,7 @@ # valid: %if "lsdfj %ksdf(sdfs) 3489" Release: %mkrel 1.2 -%else %else +%else Release: 0 %endif # requiere a well defined value: @@ -163,16 +163,16 @@ %defattr(-,root,root) %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version} %{_datadir}/applications/kde4/fedora-kradioripper.desktop -%else %else +%else %{_datadir}/applications/kde4/kradioripper.desktop %endif %{_bindir}/kradioripper %{_datadir}/locale/*/LC_MESSAGES/kradioripper.mo %if 0%{?mandriva_version} # TODO The %%doc macro is actually broken for mandriva 2009 in build service... %dir %{_datadir}/apps/kradioripper %{_datadir}/apps/kradioripper/* -%else %else +%else %doc COPYING LICENSE LICENSE.GPL2 LICENSE.GPL3 NEWS WARRANTY %dir %{_datadir}/kde4/apps/kradioripper %{_datadir}/kde4/apps/kradioripper/* diff --git a/autotests/folding/highlight.t2t.fold b/autotests/folding/highlight.t2t.fold --- a/autotests/folding/highlight.t2t.fold +++ b/autotests/folding/highlight.t2t.fold @@ -9,10 +9,10 @@ %!--include: menu.t2t -= Title 1 == Title 1 = += Title 1 = -== My Subtitle 1 ==[some definition]== My Subtitle 1 ==[some definition] +== My Subtitle 1 ==[some definition] Some examples: @@ -42,15 +42,15 @@ ``` -== My Subtitle 2 ==== My Subtitle 2 == +== My Subtitle 2 == Lorem ipsum etc Lorem ipsum etc Lorem ipsum etc - Test d'écriture avec des accents à la française. Ça marche ou pas ? -== My Subtitle 3 ==== My Subtitle 3 == +== My Subtitle 3 == Lorem ipsum etc @@ -63,7 +63,7 @@ -=== My Subsubtitle 1 ====== My Subsubtitle 1 === +=== My Subsubtitle 1 === //It's a level 3 header// @@ -73,7 +73,7 @@ - list 3 -=== My Subsubtitle 2 ====== My Subsubtitle 2 === +=== My Subsubtitle 2 === //It's another level 3 header// @@ -84,7 +84,7 @@ + list 3 -== My Subtitle 4 ==== My Subtitle 4 == +== My Subtitle 4 == nothing to say here... diff --git a/autotests/folding/highlight.y.fold b/autotests/folding/highlight.y.fold --- a/autotests/folding/highlight.y.fold +++ b/autotests/folding/highlight.y.fold @@ -48,7 +48,7 @@ @$.initialize (file_name); }; -%%%% +%% prog: KW_PROGRAM ident { parser->start($2); } prog_beg_glob_decl instructions { parser->endproc(0); } dev_procedures KW_ENDP ; @@ -82,7 +82,7 @@ | gram2 ;; -%%%% +%% #include diff --git a/autotests/folding/test.desktop.fold b/autotests/folding/test.desktop.fold --- a/autotests/folding/test.desktop.fold +++ b/autotests/folding/test.desktop.fold @@ -1,5 +1,5 @@ # test file for .dekstop syntax highlighting -[Desktop Entry][Desktop Entry] +[Desktop Entry] GenericName=Text Editor GenericName[ar]=محرّر نصوص Name=KWrite @@ -17,3 +17,17 @@ X-DBUS-StartupType=Multi X-DBUS-ServiceName=org.kde.kwrite Categories=Qt;KDE;Utility;TextEditor; +Actions=new-window;new-tab; + +# test folding: the header should not be +# part of the previous region. +# NOTE: this options in Exec don't exist. +[Desktop Action new-window] +Name=New Window +Exec=kwrite --new-window +Icon=kwrite + +[Desktop Action new-tab] +Name=New Tab +Exec=kwrite --new-tab +Icon=kwrite diff --git a/autotests/folding/test.ini.fold b/autotests/folding/test.ini.fold --- a/autotests/folding/test.ini.fold +++ b/autotests/folding/test.ini.fold @@ -2,15 +2,15 @@ ; comment with ### alerts # alternative comments -[Empty section][Empty section] +[Empty section] -[Section 2][Section 2] +[Section 2] Key1=String Value Key2=42 Key3=3.14 Key\SubKey=True -[Section 3][Section 3] +[Section 3] ; = in values are fine ; inline comments are not supported, ;/# are part of the value key4 = foo = True; bar = False diff --git a/autotests/folding/usr.bin.apparmor-profile-test.fold b/autotests/folding/usr.bin.apparmor-profile-test.fold --- a/autotests/folding/usr.bin.apparmor-profile-test.fold +++ b/autotests/folding/usr.bin.apparmor-profile-test.fold @@ -183,12 +183,12 @@ # Error: Open rule /home/*/file rw - capability dac_overridecapability dac_override + capability dac_override deny file /etc/fstab w audit network ieee802154, dbus (receive - unix stream,unix stream, + unix stream, unix stream, } @@ -206,16 +206,16 @@ remount remount remount, dbus remount - remount,remount, + remount, unix remount - remount,remount, + remount, # "unix" keyword network unix unix, ptrace unix - unix,unix, + unix, unix unix - unix,unix, + unix, # Transition rules /usr/bin/foo cx -> hello*, diff --git a/autotests/html/test.desktop.html b/autotests/html/test.desktop.html --- a/autotests/html/test.desktop.html +++ b/autotests/html/test.desktop.html @@ -23,4 +23,18 @@ X-DBUS-StartupType=Multi X-DBUS-ServiceName=org.kde.kwrite Categories=Qt;KDE;Utility;TextEditor; +Actions=new-window;new-tab; + +# test folding: the header should not be +# part of the previous region. +# NOTE: this options in Exec don't exist. +[Desktop Action new-window] +Name=New Window +Exec=kwrite --new-window +Icon=kwrite + +[Desktop Action new-tab] +Name=New Tab +Exec=kwrite --new-tab +Icon=kwrite diff --git a/autotests/input/test.desktop b/autotests/input/test.desktop --- a/autotests/input/test.desktop +++ b/autotests/input/test.desktop @@ -17,3 +17,17 @@ X-DBUS-StartupType=Multi X-DBUS-ServiceName=org.kde.kwrite Categories=Qt;KDE;Utility;TextEditor; +Actions=new-window;new-tab; + +# test folding: the header should not be +# part of the previous region. +# NOTE: this options in Exec don't exist. +[Desktop Action new-window] +Name=New Window +Exec=kwrite --new-window +Icon=kwrite + +[Desktop Action new-tab] +Name=New Tab +Exec=kwrite --new-tab +Icon=kwrite diff --git a/autotests/reference/test.desktop.ref b/autotests/reference/test.desktop.ref --- a/autotests/reference/test.desktop.ref +++ b/autotests/reference/test.desktop.ref @@ -17,3 +17,17 @@ X-DBUS-StartupType=Multi
X-DBUS-ServiceName=org.kde.kwrite
Categories=Qt;KDE;Utility;TextEditor;
+Actions=new-window;new-tab;
+
+# test folding: the header should not be
+# part of the previous region.
+# NOTE: this options in Exec don't exist.
+
[Desktop Action new-window]

+Name=New Window
+Exec=kwrite --new-window
+Icon=kwrite
+
+
[Desktop Action new-tab]

+Name=New Tab
+Exec=kwrite --new-tab
+Icon=kwrite
diff --git a/src/lib/abstracthighlighter.cpp b/src/lib/abstracthighlighter.cpp --- a/src/lib/abstracthighlighter.cpp +++ b/src/lib/abstracthighlighter.cpp @@ -251,8 +251,15 @@ if (newOffset <= offset) continue; - // apply folding - if (rule->endRegion().isValid()) + /** + * apply folding. + * special cases: + * - rule with endRegion + beginRegion: in endRegion, the length is 0 + * - rule with lookAhead: length is 0 + */ + if (rule->endRegion().isValid() && rule->beginRegion().isValid()) + applyFolding(offset, 0, rule->endRegion()); + else if (rule->endRegion().isValid()) applyFolding(offset, rule->isLookAhead() ? 0 : newOffset - offset, rule->endRegion()); if (rule->beginRegion().isValid()) applyFolding(offset, rule->isLookAhead() ? 0 : newOffset - offset, rule->beginRegion());