@@ -700,6 +700,79 @@ defmodule NextLS.CompletionsTest do
700700 assert_match % { "kind" => 6 , "label" => "ast1" } not in results
701701 end
702702
703+ test "with else" , % { client: client , foo: foo } do
704+ uri = uri ( foo )
705+
706+ did_open ( client , foo , """
707+ defmodule Foo do
708+ def run(doug) do
709+ completion_item =
710+ with {:ok, darrel} <- completion_item.data do
711+ darrel
712+ else
713+ %{"uri" => uri, "data" => data} ->
714+ d
715+
716+ end
717+ end
718+ """ )
719+
720+ request client , % {
721+ method: "textDocument/completion" ,
722+ id: 2 ,
723+ jsonrpc: "2.0" ,
724+ params: % {
725+ textDocument: % { uri: uri } ,
726+ position: % {
727+ line: 7 ,
728+ character: 11
729+ }
730+ }
731+ }
732+
733+ assert_result 2 , results
734+
735+ assert_match % { "kind" => 6 , "label" => "doug" } in results
736+ assert_match % { "kind" => 6 , "label" => "data" } in results
737+
738+ assert_match % { "kind" => 6 , "label" => "darrel" } not in results
739+ end
740+
741+ test "for comprehension" , % { client: client , foo: foo } do
742+ uri = uri ( foo )
743+
744+ did_open ( client , foo , """
745+ defmodule Foo do
746+ def run(items) do
747+ for item <- items,
748+ iname = item.name,
749+ String.starts_with?(name, "Mitch") do
750+ i
751+ end
752+ end
753+ """ )
754+
755+ request client , % {
756+ method: "textDocument/completion" ,
757+ id: 2 ,
758+ jsonrpc: "2.0" ,
759+ params: % {
760+ textDocument: % { uri: uri } ,
761+ position: % {
762+ line: 5 ,
763+ character: 7
764+ }
765+ }
766+ }
767+
768+ assert_result 2 , results
769+
770+ assert_match % { "kind" => 6 , "label" => "item" } in results
771+ assert_match % { "kind" => 6 , "label" => "iname" } in results
772+
773+ assert_match % { "kind" => 6 , "label" => "items" } in results
774+ end
775+
703776 test "variables show up in test blocks" , % { client: client , foo: foo } do
704777 uri = uri ( foo )
705778
0 commit comments