From afddb87cd4afef6ae00ad8d3d09e1e189eee5be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 14 Dec 2017 12:12:33 +0100 Subject: [PATCH] [apps] In toolbox helpers, add double single quotes in text from command and insert cursor in the middle of both --- apps/shared/toolbox_helpers.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/shared/toolbox_helpers.cpp b/apps/shared/toolbox_helpers.cpp index 5fb4c51df..333a38171 100644 --- a/apps/shared/toolbox_helpers.cpp +++ b/apps/shared/toolbox_helpers.cpp @@ -6,7 +6,7 @@ namespace ToolboxHelpers { int CursorIndexInCommand(const char * text) { for (size_t i = 0; i < strlen(text); i++) { - if (text[i] == '(') { + if (text[i] == '(' || text[i] == '\'') { return i + 1; } } @@ -21,21 +21,23 @@ void TextToInsertForCommandMessage(I18n::Message message, char * buffer) { void TextToInsertForCommandText(const char * command, char * buffer) { int currentNewTextIndex = 0; int numberOfOpenBrackets = 0; + bool insideQuote = false; size_t commandLength = strlen(command); for (size_t i = 0; i < commandLength; i++) { if (command[i] == ')') { numberOfOpenBrackets--; } - if (numberOfOpenBrackets == 0 || command[i] == ',') - { - buffer[currentNewTextIndex] = command[i]; - buffer[currentNewTextIndex + 1] = 0; - currentNewTextIndex++; + if ((numberOfOpenBrackets == 0 || command[i] == ',') && (!insideQuote || command[i] == '\'')) { + buffer[currentNewTextIndex++] = command[i]; } if (command[i] == '(') { numberOfOpenBrackets++; } + if (command[i] == '\'') { + insideQuote = !insideQuote; + } } + buffer[currentNewTextIndex] = 0; } }