[LyX/2.1.x] Do not attempt to select an empty cell before inserting a longtable caption

2015-07-28 Thread Juergen Spitzmueller
commit 0f9c2b4f047e7d2f316a7a0eb0a187e992c560b8
Author: Juergen Spitzmueller sp...@lyx.org
Date:   Sat Jul 25 12:48:13 2015 +0200

Do not attempt to select an empty cell before inserting a longtable caption

Fixes: #9692

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 1807bcb..3013db7 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -5930,7 +5930,9 @@ void InsetTabular::tabularFeatures(Cursor  cur,
cur.setSelection(false);
// If a row is set as caption, then also insert
// a caption. Otherwise the LaTeX output is broken.
-   lyx::dispatch(FuncRequest(LFUN_INSET_SELECT_ALL));
+   // Select cell if it is non-empty
+   if (cur.lastpos()  0 || cur.lastpit()  0)
+   lyx::dispatch(FuncRequest(LFUN_INSET_SELECT_ALL));
lyx::dispatch(FuncRequest(LFUN_CAPTION_INSERT));
break;
}
diff --git a/status.21x b/status.21x
index e32d2a1..a63ee23 100644
--- a/status.21x
+++ b/status.21x
@@ -63,7 +63,8 @@ What's new
 
 * USER INTERFACE
 
-
+- Fix automatic insertion of longtable captions (bug 9692).
+ 
 
 * INTERNALS
 


[LyX/2.1.x] Do not attempt to select an empty cell before inserting a longtable caption

2015-07-28 Thread Juergen Spitzmueller
commit 0f9c2b4f047e7d2f316a7a0eb0a187e992c560b8
Author: Juergen Spitzmueller 
Date:   Sat Jul 25 12:48:13 2015 +0200

Do not attempt to select an empty cell before inserting a longtable caption

Fixes: #9692

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 1807bcb..3013db7 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -5930,7 +5930,9 @@ void InsetTabular::tabularFeatures(Cursor & cur,
cur.setSelection(false);
// If a row is set as caption, then also insert
// a caption. Otherwise the LaTeX output is broken.
-   lyx::dispatch(FuncRequest(LFUN_INSET_SELECT_ALL));
+   // Select cell if it is non-empty
+   if (cur.lastpos() > 0 || cur.lastpit() > 0)
+   lyx::dispatch(FuncRequest(LFUN_INSET_SELECT_ALL));
lyx::dispatch(FuncRequest(LFUN_CAPTION_INSERT));
break;
}
diff --git a/status.21x b/status.21x
index e32d2a1..a63ee23 100644
--- a/status.21x
+++ b/status.21x
@@ -63,7 +63,8 @@ What's new
 
 * USER INTERFACE
 
-
+- Fix automatic insertion of longtable captions (bug 9692).
+ 
 
 * INTERNALS