1
1
import { compact } from '@zardoy/utils'
2
2
import postfixesAtPosition from '../completions/postfixesAtPosition'
3
3
import { NodeAtPositionResponse , RequestOptionsTypes , RequestResponseTypes , TriggerCharacterCommand , triggerCharacterCommands } from '../ipcTypes'
4
- import { findChildContainingPosition , getNodePath } from '../utils'
4
+ import { findChildContainingExactPosition , findChildContainingPosition , getNodePath } from '../utils'
5
5
import getEmmetCompletions from './emmet'
6
6
import objectIntoArrayConverters from './objectIntoArrayConverters'
7
7
@@ -121,7 +121,7 @@ export default (
121
121
}
122
122
}
123
123
if ( specialCommand === 'getRangeOfSpecialValue' ) {
124
- let node = findChildContainingPosition ( ts , sourceFile , position )
124
+ let node = findChildContainingExactPosition ( sourceFile , position )
125
125
if ( ! node ) return
126
126
let targetNode : undefined | ts . Node | [ number , number ]
127
127
if ( ts . isIdentifier ( node ) && node . parent ) {
@@ -130,6 +130,9 @@ export default (
130
130
targetNode = node . initializer
131
131
} else if ( 'body' in node ) {
132
132
targetNode = node . body as ts . Node
133
+ } else if ( ts . isJsxOpeningElement ( node ) || ts . isJsxOpeningFragment ( node ) || ts . isJsxSelfClosingElement ( node ) ) {
134
+ const pos = node . end
135
+ targetNode = [ pos , pos ]
133
136
}
134
137
}
135
138
@@ -156,6 +159,10 @@ export default (
156
159
targetNode = n . thenStatement
157
160
return true
158
161
}
162
+ if ( ts . isIfStatement ( n ) && position < n . thenStatement . pos ) {
163
+ targetNode = n . thenStatement
164
+ return true
165
+ }
159
166
return false
160
167
} )
161
168
}
0 commit comments