@@ -1596,6 +1596,9 @@ impl<'a> Transaction<'a> {
15961596 position : TextSize ,
15971597 covering_nodes : & [ AnyNodeRef ] ,
15981598 ) -> Result < Option < ( Type , Name ) > , EmptyResponseReason > {
1599+ let module = self
1600+ . get_module_info ( handle)
1601+ . ok_or ( EmptyResponseReason :: ModuleInfoNotFound ) ?;
15991602 // Look up the type of an expression, distinguishing "no answers"
16001603 // from "answers available but no type trace for this range."
16011604 let type_at = |range : TextRange | -> Result < Type , EmptyResponseReason > {
@@ -1680,11 +1683,18 @@ impl<'a> Transaction<'a> {
16801683 } ) )
16811684 }
16821685 AnyNodeRef :: ExprSubscript ( subscript) => {
1683- if !Self :: position_is_between (
1684- position,
1686+ let between = TextRange :: new (
16851687 subscript. value . range ( ) . end ( ) ,
16861688 subscript. slice . range ( ) . start ( ) ,
1687- ) {
1689+ ) ;
1690+ let suffix = module. code_at ( TextRange :: new (
1691+ subscript. value . range ( ) . end ( ) ,
1692+ subscript. range ( ) . end ( ) ,
1693+ ) ) ;
1694+ if position >= subscript. slice . range ( ) . start ( )
1695+ || !between. contains ( position)
1696+ || !suffix. chars ( ) . next ( ) . is_some_and ( char:: is_whitespace)
1697+ {
16881698 return None ;
16891699 }
16901700 let dunder_name = match subscript. ctx {
0 commit comments