|
|
|
|
@ -7,6 +7,31 @@
|
|
|
|
|
#include <io.h> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
std::string escape_text(std::string text) { |
|
|
|
|
for(size_t c = 0; c < text.size(); ++c) { |
|
|
|
|
if(text[c] == '\n') { |
|
|
|
|
text.replace(c, 1, "\\n"); |
|
|
|
|
++c; |
|
|
|
|
} |
|
|
|
|
else if(text[c] == '\r') { |
|
|
|
|
text.replace(c, 1, "\\r"); |
|
|
|
|
++c; |
|
|
|
|
} |
|
|
|
|
else if(text[c] == '\t') { |
|
|
|
|
text.replace(c, 1, "\\t"); |
|
|
|
|
++c; |
|
|
|
|
} |
|
|
|
|
else if(text[c] == '"') { |
|
|
|
|
text.replace(c, 1, "\\\""); |
|
|
|
|
++c; |
|
|
|
|
} |
|
|
|
|
else if(text[c] == '\\') { |
|
|
|
|
text.replace(c, 1, "\\\\"); |
|
|
|
|
++c; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return text; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main() { |
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
@ -447,7 +472,7 @@ int main() {
|
|
|
|
|
"id": "5", |
|
|
|
|
"result": [ |
|
|
|
|
{ |
|
|
|
|
"uri": "file://)" + file_path.string() + |
|
|
|
|
"uri": "file://)" + escape_text(file_path.string()) + |
|
|
|
|
R"(", |
|
|
|
|
"range": { |
|
|
|
|
"start": { |
|
|
|
|
@ -461,7 +486,7 @@ int main() {
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"uri": "file://)" + file_path.string() + |
|
|
|
|
"uri": "file://)" + escape_text(file_path.string()) + |
|
|
|
|
R"(", |
|
|
|
|
"range": { |
|
|
|
|
"start": { |
|
|
|
|
|