Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tsconfig.strictNullChecks.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"./vs/editor/contrib/find/replacePattern.ts",
"./vs/editor/contrib/find/simpleFindWidget.ts",
"./vs/editor/contrib/find/test/find.test.ts",
"./vs/editor/contrib/find/test/findController.test.ts",
"./vs/editor/contrib/find/test/replacePattern.test.ts",
"./vs/editor/contrib/folding/folding.ts",
"./vs/editor/contrib/folding/foldingDecorations.ts",
Expand Down
8 changes: 4 additions & 4 deletions src/vs/editor/contrib/find/findController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export class StartFindAction extends EditorAction {
});
}

public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
public run(accessor: ServicesAccessor | null, editor: ICodeEditor): void {
let controller = CommonFindController.get(editor);
if (controller) {
controller.start({
Expand Down Expand Up @@ -488,7 +488,7 @@ export class StartFindWithSelectionAction extends EditorAction {
}
}
export abstract class MatchFindAction extends EditorAction {
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
public run(accessor: ServicesAccessor | null, editor: ICodeEditor): void {
let controller = CommonFindController.get(editor);
if (controller && !this._run(controller)) {
controller.start({
Expand Down Expand Up @@ -551,7 +551,7 @@ export class PreviousMatchFindAction extends MatchFindAction {
}

export abstract class SelectionMatchFindAction extends EditorAction {
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
public run(accessor: ServicesAccessor | null, editor: ICodeEditor): void {
let controller = CommonFindController.get(editor);
if (!controller) {
return;
Expand Down Expand Up @@ -641,7 +641,7 @@ export class StartFindReplaceAction extends EditorAction {
});
}

public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
public run(accessor: ServicesAccessor | null, editor: ICodeEditor): void {
if (!editor.hasModel() || editor.getConfiguration().readOnly) {
return;
}
Expand Down
38 changes: 19 additions & 19 deletions src/vs/editor/contrib/find/test/findController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export class TestFindController extends CommonFindController {
}
}

function fromRange(rng: Range): number[] {
return [rng.startLineNumber, rng.startColumn, rng.endLineNumber, rng.endColumn];
function fromSelection(slc: Selection | null): number[] {
return [slc!.startLineNumber, slc!.startColumn, slc!.endLineNumber, slc!.endColumn];
}

suite('FindController', () => {
Expand All @@ -68,7 +68,7 @@ suite('FindController', () => {
getInteger: (key: string) => undefined,
store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); },
remove: (key) => void 0
} as IStorageService);
} as any);

if (platform.isMacintosh) {
serviceCollection.set(IClipboardService, <any>{
Expand Down Expand Up @@ -122,7 +122,7 @@ suite('FindController', () => {
nextMatchFindAction.run(null, editor);
assert.equal(findState.searchString, 'ABC');

assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]);
assert.deepEqual(fromSelection(editor.getSelection()), [1, 1, 1, 4]);

findController.dispose();
});
Expand Down Expand Up @@ -175,14 +175,14 @@ suite('FindController', () => {
findState.change({ searchString: 'ABC' }, true);

// The first ABC is highlighted.
assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]);
assert.deepEqual(fromSelection(editor.getSelection()), [1, 1, 1, 4]);

// I hit Esc to exit the Find dialog.
findController.closeFindWidget();
findController.hasFocus = false;

// The cursor is now at end of the first line, with ABC on that line highlighted.
assert.deepEqual(fromRange(editor.getSelection()), [1, 1, 1, 4]);
assert.deepEqual(fromSelection(editor.getSelection()), [1, 1, 1, 4]);

// I hit delete to remove it and change the text to XYZ.
editor.pushUndoStop();
Expand All @@ -195,10 +195,10 @@ suite('FindController', () => {
// ABC
// XYZ
// ABC
assert.equal(editor.getModel().getLineContent(1), 'XYZ');
assert.equal(editor.getModel()!.getLineContent(1), 'XYZ');

// The cursor is at end of the first line.
assert.deepEqual(fromRange(editor.getSelection()), [1, 4, 1, 4]);
assert.deepEqual(fromSelection(editor.getSelection()), [1, 4, 1, 4]);

// I hit F3 to "Find Next" to find the next occurrence of ABC, but instead it searches for XYZ.
nextMatchFindAction.run(null, editor);
Expand All @@ -224,10 +224,10 @@ suite('FindController', () => {
});

nextMatchFindAction.run(null, editor);
assert.deepEqual(fromRange(editor.getSelection()), [1, 26, 1, 29]);
assert.deepEqual(fromSelection(editor.getSelection()), [1, 26, 1, 29]);

nextMatchFindAction.run(null, editor);
assert.deepEqual(fromRange(editor.getSelection()), [1, 8, 1, 11]);
assert.deepEqual(fromSelection(editor.getSelection()), [1, 8, 1, 11]);

findController.dispose();
});
Expand All @@ -250,10 +250,10 @@ suite('FindController', () => {
startFindAction.run(null, editor);

nextMatchFindAction.run(null, editor);
assert.deepEqual(fromRange(editor.getSelection()), [2, 9, 2, 13]);
assert.deepEqual(fromSelection(editor.getSelection()), [2, 9, 2, 13]);

nextMatchFindAction.run(null, editor);
assert.deepEqual(fromRange(editor.getSelection()), [1, 9, 1, 13]);
assert.deepEqual(fromSelection(editor.getSelection()), [1, 9, 1, 13]);

findController.dispose();
});
Expand Down Expand Up @@ -330,7 +330,7 @@ suite('FindController', () => {
findController.getState().change({ searchString: '\\b\\s{3}\\b', replaceString: ' ', isRegex: true }, false);
findController.moveToNextMatch();

assert.deepEqual(editor.getSelections().map(fromRange), [
assert.deepEqual(editor.getSelections()!.map(fromSelection), [
[1, 39, 1, 42]
]);

Expand All @@ -357,7 +357,7 @@ suite('FindController', () => {
findController.getState().change({ searchString: '^', replaceString: 'x', isRegex: true }, false);
findController.moveToNextMatch();

assert.deepEqual(editor.getSelections().map(fromRange), [
assert.deepEqual(editor.getSelections()!.map(fromSelection), [
[2, 1, 2, 1]
]);

Expand Down Expand Up @@ -388,7 +388,7 @@ suite('FindController', () => {
// cmd+f3
nextSelectionMatchFindAction.run(null, editor);

assert.deepEqual(editor.getSelections().map(fromRange), [
assert.deepEqual(editor.getSelections()!.map(fromSelection), [
[3, 1, 3, 9]
]);

Expand Down Expand Up @@ -419,7 +419,7 @@ suite('FindController', () => {
// cmd+f3
nextSelectionMatchFindAction.run(null, editor);

assert.deepEqual(editor.getSelections().map(fromRange), [
assert.deepEqual(editor.getSelections()!.map(fromSelection), [
[3, 1, 3, 9]
]);

Expand All @@ -443,7 +443,7 @@ suite('FindController query options persistence', () => {
getInteger: (key: string) => undefined,
store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); },
remove: (key) => void 0
} as IStorageService);
} as any);

test('matchCase', () => {
withTestCodeEditor([
Expand All @@ -464,7 +464,7 @@ suite('FindController query options persistence', () => {
// I type ABC.
findState.change({ searchString: 'ABC' }, true);
// The second ABC is highlighted as matchCase is true.
assert.deepEqual(fromRange(editor.getSelection()), [2, 1, 2, 4]);
assert.deepEqual(fromSelection(editor.getSelection()), [2, 1, 2, 4]);

findController.dispose();
});
Expand All @@ -491,7 +491,7 @@ suite('FindController query options persistence', () => {
// I type AB.
findState.change({ searchString: 'AB' }, true);
// The second AB is highlighted as wholeWord is true.
assert.deepEqual(fromRange(editor.getSelection()), [2, 1, 2, 3]);
assert.deepEqual(fromSelection(editor.getSelection()), [2, 1, 2, 3]);

findController.dispose();
});
Expand Down