Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue #19

  • Loading branch information...
commit 1a604ba3fe36a73ddc264ea526dcebc3f9b78784 1 parent ef79a70
@chrisbra authored
Showing with 27 additions and 15 deletions.
  1. +8 −0 autoload/nrrwrgn.vim
  2. +19 −15 doc/NarrowRegion.txt
View
8 autoload/nrrwrgn.vim
@@ -810,11 +810,19 @@ fun! nrrwrgn#WidenRegion(force) "{{{1
let instn = b:nrrw_instn
let close = has_key(s:nrrw_rgn_lines[instn], 'single')
let vmode = has_key(s:nrrw_rgn_lines[instn], 'vmode')
+ " Save current state
+ let nr = changenr()
" Execute autocommands
if has_key(s:nrrw_aucmd, "close")
exe s:nrrw_aucmd["close"]
endif
let cont = getline(1,'$')
+ if has_key(s:nrrw_aucmd, "close") && nr != changenr()
+ " Restore buffer contents before the autocommand
+ " (in case the window isn't closed, the user sees
+ " the correct input)
+ exe "undo" nr
+ endif
let tab=<sid>BufInTab(orig_buf)
if tab != tabpagenr() && tab > 0
View
34 doc/NarrowRegion.txt
@@ -2,7 +2,7 @@
Author: Christian Brabandt <cb@256bit.org>
Version: 0.31 Sat, 16 Feb 2013 22:28:31 +0100
-Copyright: (c) 2009, 2010, 2011, 2012 by Christian Brabandt
+Copyright: (c) 2009-2013 by Christian Brabandt
The VIM LICENSE applies to NrrwRgnPlugin.vim and NrrwRgnPlugin.txt
(see |copyright|) except use NrrwRgnPlugin instead of "Vim".
NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK.
@@ -44,7 +44,7 @@ This plugin defines the following commands:
*:NarrowRegion* *:NR*
:[range]NR[!]
:[range]NarrowRegion[!] When [range] is omitted, select only the current
- line, else use the lines in the range given and
+ line, else use the lines in the range given and
open it in a new Scratch Window.
If the current line is selected and is on a folded
region, select the whole folded text.
@@ -56,7 +56,7 @@ This plugin defines the following commands:
*:NarrowWindow* *:NW*
:NW[!]
:NarrowWindow[!] Select only the range that is visible the current
- window and open it in a new Scratch Window.
+ window and open it in a new Scratch Window.
Whenever you are finished modifying that region
simply write the buffer.
If ! is given, open the narrowed buffer not in a
@@ -64,7 +64,7 @@ This plugin defines the following commands:
with 'hidden' set).
*:WidenRegion*
-:WidenRegion[!] This command is only available in the narrowed
+:WidenRegion[!] This command is only available in the narrowed
scratch window. If the buffer has been modified,
the contents will be put back on the original
buffer. If ! is specified, the window will be
@@ -125,9 +125,9 @@ This plugin defines the following commands:
the changes back to the original buffer.
*:NRL*
-
+
:NRL[!] Reselect the last selected region again and open
- in a narrowed window.
+ in a narrowed window.
If ! is given, open the narrowed buffer not in a
split buffer but in the current window (works best
with 'hidden' set).
@@ -177,7 +177,7 @@ changes but when you write your changes back, these comments will stay in your
file. You would do it like this: >
:v/^#/NRP
:NRMulti
-<
+<
Now a Narrowed Window will open, that contains only the configuration lines.
Each block of independent region will be separated by a string like
@@ -265,7 +265,7 @@ If you want to use several independent narrowed regions of the same buffer
that you want to write at the same time, protecting the original buffer is not
really useful. Therefore, set the g:nrrw_rgn_protect variable, e.g. in your
|.vimrc| >
-
+
let g:nrrw_rgn_protect = 'n'
<
This can be useful if you diff different regions of the same file, and want
@@ -280,7 +280,7 @@ back into the original buffer, but it can't guarantee that this will work and
might fail silently. Therefore, this feature is experimental!
------------------------------------------------------------------------------
- *NR-hooks*
+ *NrrwRgn-hook* *NR-hooks*
NarrowRegion can execute certain commands, when creating the narrowed window
and when closing the narrowed window. For this, you can set 2 buffer-local
@@ -291,7 +291,7 @@ For example, suppose you have a file, containing columns separated data (CSV
format) which you want to modify and you also have the CSV filetype plugin
(http://www.vim.org/scripts/script.php?script_id=2830) installed and you want
to modify the CSV data which should be visually arranged like a table in the
-narrowed window.
+narrowed window.
Therefore you want the command |:ArrangeColumn| to be executed in the new
narrowed window upon entering it, and when writing the changes back, you want
@@ -307,7 +307,7 @@ This will execute the commands in the narrowed window: >
:%ArrangeCol
and before writing the changes back, it'll execute: >
-
+
:%UnArrangeCol
==============================================================================
@@ -331,7 +331,11 @@ looking at my Amazon whishlist: http://www.amazon.de/wishlist/2BKAHE8J7Z6UW
4. NrrwRgn History *NrrwRgn-history*
-0.31: Feb 16, 2013
+0.32 (unreleased)
+- hooks could corrupt the narrowed buffer, if it wasn't closed (reported by
+ jszakemeister https://github.com/chrisbra/NrrwRgn/issues/17, thanks!)

I think you meant issues/19 here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+0.31: Feb 16, 2013 {{{1
- NRM threw some errors (reported by pydave in
https://github.com/chrisbra/NrrwRgn/issues/17, thanks!)
- don't create swapfiles (reported by ping, thanks!)
@@ -393,7 +397,7 @@ looking at my Amazon whishlist: http://www.amazon.de/wishlist/2BKAHE8J7Z6UW
0.23: Oct 24, 2011 {{{1
- (wrongly uploaded to vim.org)
-
+
0.22: Oct 24, 2011 {{{1
- Allow customization via the use of hooks (|NR-hooks|)
@@ -495,7 +499,7 @@ looking at my Amazon whishlist: http://www.amazon.de/wishlist/2BKAHE8J7Z6UW
bufnr(), so it should work without problems for several buffers)
- switch from script local variables to buffer local variables, so narrowing
for several buffers should work.
-- set 'winfixheight' for narrowed window
+- set 'winfixheight' for narrowed window
- Added command :NRV (suggested by Charles Campbell, thanks!)
- added error handling, in case :NRV is called, without a selected region
- take care of beeps, when calling :NRV
@@ -526,7 +530,7 @@ looking at my Amazon whishlist: http://www.amazon.de/wishlist/2BKAHE8J7Z6UW
- Highlight narrowed region in the original buffer
- Save and Restore search-register
-- Provide shortcut commands |:NR|
+- Provide shortcut commands |:NR|
- Provide command |:NW| and |:NarrowWindow|
- Make plugin autoloadable
- Enable GLVS (see |:GLVS|)
Please sign in to comment.
Something went wrong with that request. Please try again.