Permalink
Browse files

• improve the regexp used to match non-comment part of lines

The previous regexp would cause a break point per character in the line and Ruby’s regexp lib “only” allow around 2,000 of these, so users with excessively long lines saw this command error out (stack overflow).

As a quick fix I made the regexp match the entire line in one go, if it does not contain any % characters. It then falls back on the old regexp (i.e. via normal regexp alternation).


git-svn-id: http://svn.textmate.org/trunk/Bundles/Latex.tmbundle@11471 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent 46f2358 commit 72f1cc422532565f636bf126a9dc38e9a7adc247 @sorbits sorbits committed Apr 13, 2009
Showing with 2 additions and 2 deletions.
  1. +2 −2 Commands/Show Outline.tmCommand
View
4 Commands/Show Outline.tmCommand
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
@@ -13,7 +13,7 @@ require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/LaTeXUtils.rb"
html_header "LaTeX Document Outline", "LaTeX"
REGEX = /\\(part|chapter|section|subsection|subsubsection|paragraph|subparagraph)\*?(?:%.*\n[ \t]*)?(?:(?&gt;\[(.*?)\])|\{([^{}]*(?:\{[^}]*\}[^}]*?)*)\})/
INCLUDE_REGEX = /\\(?:input|include)(?:%.*\n[ \t]*)?(?&gt;\{(.*?)\})/
-NON_COMMENT_REGEX = /^((?:[^%]|\\%)*)(?=%|$)/
+NON_COMMENT_REGEX = /^([^%]+$|(?:[^%]|\\%)*)(?=%|$)/
class String
def adjust_end(new_piece)
new_form = self.sub(/[^\/]*$/,new_piece)

0 comments on commit 72f1cc4

Please sign in to comment.