Le 02/07/2018 à 15:53, Daniel a écrit :
On 26/06/2018 05:46, Richard Kimberly Heck wrote:
The following feels `intuitive' to me: At the end of an
InsetCollapsable, press the space bar twice to exit the inset and return
to the enclosing one. The first space is a real space, but the next one
would remove that space and exit the inset.

Thoughts? Better yet, code? I'm afraid I have no idea how to do that.

I thought insets could be set to honor extra spaces. Would't this be inconsistent with the suggestion?

Something like the attached would work. However, it does not look whether we typed two spaces; when we type a space, it looks whether there was a space before that. This is a bit different IMO.

Please play with it. Note also that this triggers undo, and this is not very nice IMO.

JMarc
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 619bbf8716..ac7d7dbc5f 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -1912,6 +1912,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 		if (cmd.argument().empty())
 			break;
 
+		Paragraph & par = cur.paragraph();
+		if (cmd.argument() == from_ascii(" ")
+		    && cur.pos() == cur.lastpos()
+		    && cur.lastpos() > 0
+		    && !par.isFreeSpacing()
+		    && par.isLineSeparator(cur.pos() - 1)
+		    && !par.isDeleted(cur.pos() - 1)) {
+			backspace(cur);
+			cur.undispatched();
+			cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+			break;
+		}
+
+
 		// Automatically delete the currently selected
 		// text and replace it with what is being
 		// typed in now. Depends on lyxrc settings

Reply via email to