From 71858cbde659212a5ee0eec2ee6fd9498b41107e Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Sat, 13 Mar 2021 02:06:06 +0100 Subject: fix bug where the new case clause wouldn't complete --- src/server/analysis.odin | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/server') diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 517d10d..0745944 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -2019,7 +2019,7 @@ fallback_position_context_completion :: proc (document: ^Document, position: com empty_arrow: bool; last_dot: bool; last_arrow: bool; - dots_seen: int; + dots_seen: int; i := position_context.position - 1; @@ -2157,9 +2157,7 @@ fallback_position_context_completion :: proc (document: ^Document, position: com if e == nil { return; - } - - else if e, ok := e.derived.(ast.Bad_Expr); ok { + } else if e, ok := e.derived.(ast.Bad_Expr); ok { return; } @@ -2411,7 +2409,14 @@ get_document_position_node :: proc (node: ^ast.Node, position_context: ^Document get_document_position(n.expr, position_context); get_document_position(n.body, position_context); case Case_Clause: - position_context.case_clause = cast(^Case_Clause)node; + + for elem in n.list { + if position_in_node(elem, position_context.position) { + position_context.case_clause = cast(^Case_Clause)node; + break; + } + } + get_document_position(n.list, position_context); get_document_position(n.body, position_context); case Switch_Stmt: -- cgit v1.2.3