Fix a few more emmet errors for strict null
This commit is contained in:
parent
336e9cebf5
commit
86999bb82b
8 changed files with 40 additions and 16 deletions
|
@ -88,9 +88,9 @@ export function wrapIndividualLinesWithAbbreviation(args: any) {
|
|||
|
||||
}
|
||||
|
||||
export function expandEmmetAbbreviation(args: any): Thenable<boolean> {
|
||||
export function expandEmmetAbbreviation(args: any): Thenable<boolean | undefined> | undefined {
|
||||
const syntax = getSyntaxFromArgs(args);
|
||||
if (!syntax || !validate()) {
|
||||
if (!syntax || !validate() || !vscode.window.activeTextEditor) {
|
||||
return fallbackTab();
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ export function expandEmmetAbbreviation(args: any): Thenable<boolean> {
|
|||
let allAbbreviationsSame: boolean = true;
|
||||
const helper = getEmmetHelper();
|
||||
|
||||
let getAbbreviation = (document: vscode.TextDocument, selection: vscode.Selection, position: vscode.Position, syntax: string): [vscode.Range, string, string] => {
|
||||
let getAbbreviation = (document: vscode.TextDocument, selection: vscode.Selection, position: vscode.Position, syntax: string): [vscode.Range | null, string, string] => {
|
||||
let rangeToReplace: vscode.Range = selection;
|
||||
let abbr = document.getText(rangeToReplace);
|
||||
if (!rangeToReplace.isEmpty) {
|
||||
|
|
|
@ -7,7 +7,13 @@ import 'mocha';
|
|||
import * as assert from 'assert';
|
||||
import { Selection, workspace } from 'vscode';
|
||||
import { withRandomFileEditor, closeAllEditors } from './testUtils';
|
||||
import { expandEmmetAbbreviation, wrapWithAbbreviation, wrapIndividualLinesWithAbbreviation } from '../abbreviationActions';
|
||||
import { expandEmmetAbbreviation as expandEmmetAbbreviationImpl, wrapWithAbbreviation, wrapIndividualLinesWithAbbreviation } from '../abbreviationActions';
|
||||
|
||||
function expandEmmetAbbreviation(args): Thenable<boolean | undefined> {
|
||||
const result = expandEmmetAbbreviationImpl(args);
|
||||
assert.ok(result);
|
||||
return result!;
|
||||
}
|
||||
|
||||
const cssContents = `
|
||||
.boo {
|
||||
|
|
|
@ -7,7 +7,13 @@ import 'mocha';
|
|||
import * as assert from 'assert';
|
||||
import { Selection } from 'vscode';
|
||||
import { withRandomFileEditor, closeAllEditors } from './testUtils';
|
||||
import { incrementDecrement } from '../incrementDecrement';
|
||||
import { incrementDecrement as incrementDecrementImpl } from '../incrementDecrement';
|
||||
|
||||
function incrementDecrement(delta): Thenable<boolean> {
|
||||
const result = incrementDecrementImpl(delta);
|
||||
assert.ok(result);
|
||||
return result!;
|
||||
}
|
||||
|
||||
suite('Tests for Increment/Decrement Emmet Commands', () => {
|
||||
teardown(closeAllEditors);
|
||||
|
|
|
@ -7,7 +7,13 @@ import 'mocha';
|
|||
import * as assert from 'assert';
|
||||
import { Selection } from 'vscode';
|
||||
import { withRandomFileEditor, closeAllEditors } from './testUtils';
|
||||
import { reflectCssValue } from '../reflectCssValue';
|
||||
import { reflectCssValue as reflectCssValueImpl } from '../reflectCssValue';
|
||||
|
||||
function reflectCssValue(): Thenable<boolean> {
|
||||
const result = reflectCssValueImpl();
|
||||
assert.ok(result);
|
||||
return result!;
|
||||
}
|
||||
|
||||
suite('Tests for Emmet: Reflect CSS Value command', () => {
|
||||
teardown(closeAllEditors);
|
||||
|
|
|
@ -45,7 +45,7 @@ suite('Tests for Emmet actions on html tags', () => {
|
|||
new Selection(5, 35, 5, 35), // cursor inside closing tag
|
||||
];
|
||||
|
||||
return updateTag('section').then(() => {
|
||||
return updateTag('section')!.then(() => {
|
||||
assert.equal(doc.getText(), expectedContents);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
@ -71,7 +71,7 @@ suite('Tests for Emmet actions on html tags', () => {
|
|||
new Selection(5, 35, 5, 35), // cursor inside closing tag
|
||||
];
|
||||
|
||||
return removeTag().then(() => {
|
||||
return removeTag()!.then(() => {
|
||||
assert.equal(doc.getText(), expectedContents);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
@ -95,7 +95,7 @@ suite('Tests for Emmet actions on html tags', () => {
|
|||
new Selection(7, 5, 7, 5), // split tag
|
||||
];
|
||||
|
||||
return splitJoinTag().then(() => {
|
||||
return splitJoinTag()!.then(() => {
|
||||
assert.equal(doc.getText(), expectedContents);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
@ -138,7 +138,7 @@ suite('Tests for Emmet actions on html tags', () => {
|
|||
new Selection(2, 3, 2, 3)
|
||||
];
|
||||
|
||||
return mergeLines().then(() => {
|
||||
return mergeLines()!.then(() => {
|
||||
assert.equal(doc.getText(), expectedContents);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
@ -153,7 +153,7 @@ suite('Tests for Emmet actions on html tags', () => {
|
|||
new Selection(5, 5, 5, 20) // selection spans multiple nodes in the same line
|
||||
];
|
||||
|
||||
return mergeLines().then(() => {
|
||||
return mergeLines()!.then(() => {
|
||||
assert.equal(doc.getText(), contents);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
|
|
@ -7,7 +7,13 @@ import 'mocha';
|
|||
import * as assert from 'assert';
|
||||
import { Selection } from 'vscode';
|
||||
import { withRandomFileEditor, closeAllEditors } from './testUtils';
|
||||
import { toggleComment } from '../toggleComment';
|
||||
import { toggleComment as toggleCommentImpl } from '../toggleComment';
|
||||
|
||||
function toggleComment(...args): Thenable<boolean> {
|
||||
const result = toggleCommentImpl(...args);
|
||||
assert.ok(result);
|
||||
return result!;
|
||||
}
|
||||
|
||||
suite('Tests for Toggle Comment action from Emmet (HTML)', () => {
|
||||
teardown(closeAllEditors);
|
||||
|
|
|
@ -54,7 +54,7 @@ suite('Tests for Emmet actions on html tags', () => {
|
|||
new Selection(11, 50, 11, 50)
|
||||
];
|
||||
|
||||
return updateImageSize().then(() => {
|
||||
return updateImageSize()!.then(() => {
|
||||
assert.equal(doc.getText(), expectedContents);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
@ -111,7 +111,7 @@ suite('Tests for Emmet actions on html tags', () => {
|
|||
new Selection(13, 50, 13, 50)
|
||||
];
|
||||
|
||||
return updateImageSize().then(() => {
|
||||
return updateImageSize()!.then(() => {
|
||||
assert.equal(doc.getText(), expectedContents);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
@ -140,7 +140,7 @@ suite('Tests for Emmet actions on html tags', () => {
|
|||
new Selection(4, 50, 4, 50)
|
||||
];
|
||||
|
||||
return updateImageSize().then(() => {
|
||||
return updateImageSize()!.then(() => {
|
||||
assert.equal(doc.getText(), expectedContents);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ export function toggleComment(): Thenable<boolean> | undefined {
|
|||
|
||||
return editor.edit(editBuilder => {
|
||||
editor.selections.reverse().forEach(selection => {
|
||||
let edits = toggleCommentInternal(editor.document, selection, rootNode);
|
||||
let edits = toggleCommentInternal(editor.document, selection, rootNode!);
|
||||
edits.forEach(x => {
|
||||
editBuilder.replace(x.range, x.newText);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue