diff --git a/autocomplete.d b/autocomplete.d index 76d2ac6..5236cf5 100644 --- a/autocomplete.d +++ b/autocomplete.d @@ -47,7 +47,8 @@ AutocompleteResponse complete(AutocompleteRequest request, string[] importPaths) auto sortedTokens = assumeSorted(tokenArray); auto beforeTokens = sortedTokens.lowerBound(cast(size_t) request.cursorPosition); - if (beforeTokens[$ - 1] == TokenType.lParen && beforeTokens.length >= 2) + + if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == TokenType.lParen) { immutable(string)[] completions; switch (beforeTokens[$ - 2].type) @@ -87,7 +88,7 @@ AutocompleteResponse complete(AutocompleteRequest request, string[] importPaths) break; } } - else if (beforeTokens[$ - 1] == TokenType.dot && beforeTokens.length >= 2) + else if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == TokenType.dot) { switch (beforeTokens[$ - 2].type) { diff --git a/client.d b/client.d index 97e126b..b3e654c 100644 --- a/client.d +++ b/client.d @@ -83,8 +83,23 @@ int main(string[] args) bool usingStdin = args.length <= 1; string fileName = usingStdin ? "stdin" : args[1]; File f = usingStdin ? stdin : File(args[1]); - ubyte[] sourceCode = usingStdin ? cast(ubyte[]) [] : uninitializedArray!(ubyte[])(f.size); - f.rawRead(sourceCode); + ubyte[] sourceCode; + if (usingStdin) + { + ubyte[4096] buf; + while (true) + { + auto b = f.rawRead(buf); + if (b.length == 0) + break; + sourceCode ~= b; + } + } + else + { + sourceCode = uninitializedArray!(ubyte[])(f.size); + f.rawRead(sourceCode); + } // Create message AutocompleteRequest request; diff --git a/editors/textadept/modules/dmd/dcd.lua b/editors/textadept/modules/dmd/dcd.lua index e350078..7588b81 100644 --- a/editors/textadept/modules/dmd/dcd.lua +++ b/editors/textadept/modules/dmd/dcd.lua @@ -72,10 +72,8 @@ function M.autocomplete(ch) local fileName = os.tmpname() local tmpFile = io.open(fileName, "w") tmpFile:write(buffer:get_text()) - local command = M.PATH_TO_DCD_CLIENT .. " -c" .. buffer.current_pos - .. " " .. fileName - print(command) - local p = io.popen(command) + local command = M.PATH_TO_DCD_CLIENT .. " -c" .. buffer.current_pos .. " " .. fileName + local p = io.popen(command, "r") local r = p:read("*a") print(r) if r ~= "\n" then