Skip to content

Commit

Permalink
no string conversion code actions for strings with carriage returns
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Dec 3, 2024
1 parent d31a391 commit 9316eaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/features/code_actions.zig
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub fn generateStringLiteralCodeActions(
};
// Check for disallowed characters and utf-8 validity
for (parsed) |c| {
if (c == '\n' or c == '\r') continue;
if (c == '\n') continue;
if (std.ascii.isControl(c)) return;
}
if (!std.unicode.utf8ValidateSlice(parsed)) return;
Expand Down
6 changes: 6 additions & 0 deletions tests/lsp_features/code_actions.zig
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ test "convert string literal to multiline - invalid" {
,
\\const foo = "\tWe use tabs";
);
// A Multi-Line String Literals can't contain carriage returns
try testConvertString(
\\const foo = "<cursor>\r";
,
\\const foo = "\r";
);
// Not in @import
try testConvertString(
\\const std = @import("<cursor>std");
Expand Down

0 comments on commit 9316eaa

Please sign in to comment.