@@ -17,8 +17,8 @@ interface ExpandAbbreviationInput {
1717 filter ?: string ;
1818}
1919
20- export function wrapWithAbbreviation ( args ) {
21- if ( ! validate ( false ) ) {
20+ export function wrapWithAbbreviation ( args : any ) {
21+ if ( ! validate ( false ) || ! vscode . window . activeTextEditor ) {
2222 return ;
2323 }
2424
@@ -50,8 +50,8 @@ export function wrapWithAbbreviation(args) {
5050 } ) ;
5151}
5252
53- export function wrapIndividualLinesWithAbbreviation ( args ) {
54- if ( ! validate ( false ) ) {
53+ export function wrapIndividualLinesWithAbbreviation ( args : any ) {
54+ if ( ! validate ( false ) || ! vscode . window . activeTextEditor ) {
5555 return ;
5656 }
5757
@@ -88,7 +88,7 @@ export function wrapIndividualLinesWithAbbreviation(args) {
8888
8989}
9090
91- export function expandEmmetAbbreviation ( args ) : Thenable < boolean > {
91+ export function expandEmmetAbbreviation ( args : any ) : Thenable < boolean > {
9292 const syntax = getSyntaxFromArgs ( args ) ;
9393 if ( ! syntax || ! validate ( ) ) {
9494 return fallbackTab ( ) ;
@@ -179,7 +179,7 @@ export function expandEmmetAbbreviation(args): Thenable<boolean> {
179179 } ) ;
180180}
181181
182- function fallbackTab ( ) : Thenable < boolean > {
182+ function fallbackTab ( ) : Thenable < boolean | undefined > | undefined {
183183 if ( vscode . workspace . getConfiguration ( 'emmet' ) [ 'triggerExpansionOnTab' ] === true ) {
184184 return vscode . commands . executeCommand ( 'tab' ) ;
185185 }
@@ -226,7 +226,8 @@ export function isValidLocationForEmmetAbbreviation(currentNode: Node, syntax: s
226226
227227 const currentHtmlNode = < HtmlNode > currentNode ;
228228 if ( currentHtmlNode . close ) {
229- return getInnerRange ( currentHtmlNode ) . contains ( position ) ;
229+ const innerRange = getInnerRange ( currentHtmlNode ) ;
230+ return ! ! innerRange && innerRange . contains ( position ) ;
230231 }
231232
232233 return false ;
@@ -247,7 +248,7 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex
247248 // Snippet to replace at multiple cursors are not the same
248249 // `editor.insertSnippet` will have to be called for each instance separately
249250 // We will not be able to maintain multiple cursors after snippet insertion
250- let insertPromises = [ ] ;
251+ let insertPromises : Thenable < boolean > [ ] = [ ] ;
251252 if ( ! insertSameSnippet ) {
252253 expandAbbrList . forEach ( ( expandAbbrInput : ExpandAbbreviationInput ) => {
253254 let expandedText = expandAbbr ( expandAbbrInput ) ;
@@ -278,7 +279,7 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex
278279/**
279280 * Expands abbreviation as detailed in given input.
280281 */
281- function expandAbbr ( input : ExpandAbbreviationInput ) : string {
282+ function expandAbbr ( input : ExpandAbbreviationInput ) : string | undefined {
282283 const helper = getEmmetHelper ( ) ;
283284 const expandOptions = helper . getExpandOptions ( input . syntax , getEmmetConfiguration ( input . syntax ) , input . filter ) ;
284285
@@ -322,7 +323,7 @@ function expandAbbr(input: ExpandAbbreviationInput): string {
322323
323324}
324325
325- function getSyntaxFromArgs ( args : any ) : string {
326+ function getSyntaxFromArgs ( args : any ) : string | undefined {
326327 let editor = vscode . window . activeTextEditor ;
327328 if ( ! editor ) {
328329 vscode . window . showInformationMessage ( 'No editor is active.' ) ;
0 commit comments