| 1126 | } |
| 1127 | |
| 1128 | bool DocumentController::openDocumentsWithSplitSeparators( Sublime::AreaIndex* index, QStringList urlsWithSeparators, bool& isFirstView ) |
| 1129 | { |
| 1130 | qCDebug(SHELL) << "opening " << urlsWithSeparators << " index " << index << " with children " << index->first() << " " << index->second() << " view-count " << index->viewCount(); |
| 1131 | if(urlsWithSeparators.isEmpty()) |
| 1132 | return true; |
| 1133 | |
| 1134 | Sublime::Area* area = Core::self()->uiControllerInternal()->activeArea(); |
| 1135 | |
| 1136 | QList<int> topLevelSeparators; // Indices of the top-level separators (with groups skipped) |
| 1137 | const QStringList separators {QStringLiteral("/"), QStringLiteral("-")}; |
| 1138 | QList<QStringList> groups; |
| 1139 | |
| 1140 | bool ret = true; |
| 1141 | |
| 1142 | { |
| 1143 | int parenDepth = 0; |
| 1144 | int groupStart = 0; |
| 1145 | for(int pos = 0; pos < urlsWithSeparators.size(); ++pos) |
| 1146 | { |
| 1147 | QString item = urlsWithSeparators[pos]; |
| 1148 | if(separators.contains(item)) |
| 1149 | { |
| 1150 | if(parenDepth == 0) |
| 1151 | topLevelSeparators << pos; |
| 1152 | }else if(item == QLatin1String("[")) |
| 1153 | { |
| 1154 | if(parenDepth == 0) |
| 1155 | groupStart = pos+1; |
| 1156 | ++parenDepth; |
| 1157 | } |
| 1158 | else if(item == QLatin1String("]")) |
| 1159 | { |
| 1160 | if(parenDepth > 0) |
| 1161 | { |
| 1162 | --parenDepth; |
| 1163 | |
| 1164 | if(parenDepth == 0) |
| 1165 | groups << urlsWithSeparators.mid(groupStart, pos-groupStart); |
| 1166 | } |
| 1167 | else{ |
| 1168 | qCDebug(SHELL) << "syntax error in " << urlsWithSeparators << ": parens do not match"; |
| 1169 | ret = false; |
| 1170 | } |
| 1171 | }else if(parenDepth == 0) |
| 1172 | { |
| 1173 | groups << (QStringList() << item); |
| 1174 | } |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | if(topLevelSeparators.isEmpty()) |
| 1179 | { |
| 1180 | if(urlsWithSeparators.size() > 1) |
| 1181 | { |
| 1182 | for (const QStringList& group : std::as_const(groups)) { |
| 1183 | ret &= openDocumentsWithSplitSeparators( index, group, isFirstView ); |
| 1184 | } |
| 1185 | }else{ |
nothing calls this directly
no test coverage detected