Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converter: Fix warning shown when converting #14

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/Converter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ namespace ChCase {
* @param text Text to be converted
* @return Result text after conversion
*/
public string convert_case (owned string text) {
public string convert_case (string text) {
string result = text;
PatternType.Pattern regex_pattern;
switch (source_case) {
case Case.SPACE_SEPARATED:
Expand Down Expand Up @@ -273,14 +274,14 @@ namespace ChCase {
for (int i = 0; i < regex_pattern.detect_patterns.length; i++) {
var regex = new Regex (regex_pattern.detect_patterns.index (i));
for (regex.match (text, 0, out match_info); match_info.matches (); match_info.next ()) {
text = regex.replace (text, text.length, 0, regex_pattern.replace_patterns.index (i));
result = regex.replace (text, text.length, 0, regex_pattern.replace_patterns.index (i));
}
}
} catch (RegexError e) {
warning (e.message);
}

return text;
return result;
}
}
}