diff --git a/src/dcd/server/autocomplete/complete.d b/src/dcd/server/autocomplete/complete.d index b3a9b4c7..4cd2dc9a 100644 --- a/src/dcd/server/autocomplete/complete.d +++ b/src/dcd/server/autocomplete/complete.d @@ -114,8 +114,14 @@ AutocompleteResponse dotCompletion(T)(T beforeTokens, const(Token)[] tokenArray, // of at the end auto t = beforeTokens[$ - 1]; if (cursorPosition - t.index >= 0 && cursorPosition - t.index <= t.text.length) + { partial = t.text[0 .. cursorPosition - t.index]; - significantTokenType = tok!"identifier"; + // issue 442 - prevent `partial` to start in the middle of a MBC + // since later there's a non-nothrow call to `toUpper` + while (partial.length && (partial[0] & 0x80)) + partial = partial[1 .. $]; + } + significantTokenType = partial.length ? tok!"identifier" : tok!""; beforeTokens = beforeTokens[0 .. $ - 1]; } else if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == tok!".") diff --git a/tests/tc_middle_of_utf/expected1.txt b/tests/tc_middle_of_utf/expected1.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/tc_middle_of_utf/file.d b/tests/tc_middle_of_utf/file.d new file mode 100644 index 00000000..e5208368 --- /dev/null +++ b/tests/tc_middle_of_utf/file.d @@ -0,0 +1 @@ +ß diff --git a/tests/tc_middle_of_utf/run.sh b/tests/tc_middle_of_utf/run.sh new file mode 100755 index 00000000..9e6d1614 --- /dev/null +++ b/tests/tc_middle_of_utf/run.sh @@ -0,0 +1,5 @@ +set -e +set -u + +../../bin/dcd-client $1 file.d -c1 > actual1.txt +diff actual1.txt expected1.txt