Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove notes_fold_ignore_code option, always enabled now!

I have over 800 notes and just tried the :RecentNotes command for the
first time in a while. It was really slow, took more than a minute..
I tried the :ShowTaggedNotes command, also very slow.

It turns out that the "improvement" to text folding which ignores # inside
code blocks was written in a very naive way, making it very slow on large
buffers (over 500 lines). I've now fixed this, making it fast enough on
large buffers to always enable the improvement and remove the option
altogether. I like it when I can remove options :-).
  • Loading branch information...
commit 4a12f53fe3907793123d27fe157e68b0cf41d4b0 1 parent 8583afe
@xolox authored
Showing with 20 additions and 34 deletions.
  1. +0 −6 README.md
  2. +20 −15 autoload/xolox/notes.vim
  3. +0 −13 doc/notes.txt
View
6 README.md
@@ -62,12 +62,6 @@ This option defines the pathname of the Python script that's used to perform acc
This option defines the pathname of the text file that stores the list of known tags used for tag name completion and the `:ShowTaggedNotes` command. The text file is created automatically when it's first needed, after that you can recreate it manually by executing `:IndexTaggedNotes` (see below).
-### The `g:notes_fold_ignore_code` option
-
-The notes syntax uses `#` to mark headings which define foldable sections of text. The notes syntax also supports embedding fragments of syntax highlighted text. Of course the plug-in should not fold lines starting with `#` inside a code block, because `#` is frequently used for single line comments! The fold function knows how to deal with this, however I suspect the current implementation to be very slow, so it's not enabled by default. If you set this variable to true the feature will be enabled:
-
- :let g:notes_fold_ignore_code = 1
-
## Commands
To edit one of your existing notes you can use Vim commands such as [:edit] [edit], [:split] [split] and [:tabedit] [tabedit] with a filename that starts with *note:* followed by (part of) the title of one of your notes, e.g.:
View
35 autoload/xolox/notes.vim
@@ -6,7 +6,7 @@
" Note: This file is encoded in UTF-8 including a byte order mark so
" that Vim loads the script using the right encoding transparently.
-let g:xolox#notes#version = '0.12.5'
+let g:xolox#notes#version = '0.12.6'
function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command.
@@ -510,7 +510,6 @@ function! s:internal_search(bang, pattern, keywords, phase2) " {{{2
endif
silent cwindow
if &buftype == 'quickfix'
- setlocal ignorecase
execute 'match IncSearch' substitute(pattern, '^/', '/\\c', '')
endif
call xolox#misc#timer#stop('notes.vim %s: Searched notes in %s.', g:xolox#notes#version, starttime)
@@ -859,27 +858,33 @@ endfunction
function! xolox#notes#foldexpr() " {{{3
" Folding expression to fold atx style Markdown headings.
- if xolox#misc#option#get('notes_fold_ignore_code', 0)
- let pos_save = getpos('.')
- call setpos('.', [0, v:lnum, 1, 0])
- let in_code = (search('{{{\|\(}}}\)', 'bnpW') == 1)
- call setpos('.', pos_save)
- if in_code
- return '='
- endif
- endif
let lastlevel = foldlevel(v:lnum - 1)
let nextlevel = match(getline(v:lnum), '^#\+\zs')
+ let retval = '='
if lastlevel <= 0 && nextlevel >= 1
- return '>' . nextlevel
+ let retval = '>' . nextlevel
elseif nextlevel >= 1
if lastlevel > nextlevel
- return '<' . nextlevel
+ let retval = '<' . nextlevel
else
- return '>' . nextlevel
+ let retval = '>' . nextlevel
endif
endif
- return '='
+ if retval != '='
+ " Check whether the change in folding introduced by 'rv'
+ " is invalidated because we're inside a code block.
+ let pos_save = getpos('.')
+ try
+ call setpos('.', [0, v:lnum, 1, 0])
+ if search('{{{\|\(}}}\)', 'bnpW') == 1
+ let retval = '='
+ endif
+ finally
+ " Always restore the cursor position!
+ call setpos('.', pos_save)
+ endtry
+ endif
+ return retval
endfunction
function! xolox#notes#foldtext() " {{{3
View
13 doc/notes.txt
@@ -135,19 +135,6 @@ known tags used for tag name completion and the |:ShowTaggedNotes| command.
The text file is created automatically when it's first needed, after that you
can recreate it manually by executing |:IndexTaggedNotes| (see below).
--------------------------------------------------------------------------------
-The *g:notes_fold_ignore_code* option
-
-The notes syntax uses '#' to mark headings which define foldable sections of
-text. The notes syntax also supports embedding fragments of syntax highlighted
-text. Of course the plug-in should not fold lines starting with '#' inside a
-code block, because '#' is frequently used for single line comments! The fold
-function knows how to deal with this, however I suspect the current
-implementation to be very slow, so it's not enabled by default. If you set
-this variable to true the feature will be enabled:
->
- :let g:notes_fold_ignore_code = 1
-
===============================================================================
*notes-commands*
Commands ~
Please sign in to comment.
Something went wrong with that request. Please try again.