mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Merge pull request #192894 from microsoft/alexd/yummy-bug
Adopting of `ensureNoDisposablesAreLeakedInTestSuite`
This commit is contained in:
commit
a17dab9466
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { MoveCaretCommand } from 'vs/editor/contrib/caretOperations/browser/moveCaretCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
|
@ -18,6 +19,8 @@ function testMoveCaretRightCommand(lines: string[], selection: Selection, expect
|
|||
|
||||
suite('Editor Contrib - Move Caret Command', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('move selection to left', function () {
|
||||
testMoveCaretLeftCommand(
|
||||
[
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ICommand } from 'vs/editor/common/editorCommon';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
|
@ -31,6 +32,8 @@ function testBlockCommentCommand(lines: string[], selection: Selection, expected
|
|||
|
||||
suite('Editor Contrib - Block Comment Command', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('empty selection wraps itself', function () {
|
||||
testBlockCommentCommand(
|
||||
[
|
||||
|
|
|
@ -5,18 +5,19 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ICommand } from 'vs/editor/common/editorCommon';
|
||||
import { EncodedTokenizationResult, IState, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { ColorId, MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { EncodedTokenizationResult, IState, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { CommentRule } from 'vs/editor/common/languages/languageConfiguration';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { NullState } from 'vs/editor/common/languages/nullTokenize';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ILinePreflightData, IPreflightData, ISimpleModel, LineCommentCommand, Type } from 'vs/editor/contrib/comment/browser/lineCommentCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
function createTestCommandHelper(commentsConfig: CommentRule, commandFactory: (accessor: ServicesAccessor, selection: Selection) => ICommand): (lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection) => void {
|
||||
return (lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection) => {
|
||||
|
@ -35,6 +36,8 @@ function createTestCommandHelper(commentsConfig: CommentRule, commandFactory: (a
|
|||
|
||||
suite('Editor Contrib - Line Comment Command', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const testLineCommentCommand = createTestCommandHelper(
|
||||
{ lineComment: '!@#', blockComment: ['<!@#', '#@!>'] },
|
||||
(accessor, sel) => new LineCommentCommand(accessor.get(ILanguageConfigurationService), sel, 4, Type.Toggle, true, true)
|
||||
|
@ -99,6 +102,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
|||
}
|
||||
|
||||
test('_analyzeLines', () => {
|
||||
const disposable = new DisposableStore();
|
||||
let r: IPreflightData;
|
||||
|
||||
r = LineCommentCommand._analyzeLines(Type.Toggle, true, createSimpleModel([
|
||||
|
@ -106,7 +110,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
|||
' ',
|
||||
' c',
|
||||
'\t\td'
|
||||
]), createBasicLinePreflightData(['//', 'rem', '!@#', '!@#']), 1, true, false, new TestLanguageConfigurationService());
|
||||
]), createBasicLinePreflightData(['//', 'rem', '!@#', '!@#']), 1, true, false, disposable.add(new TestLanguageConfigurationService()));
|
||||
if (!r.supported) {
|
||||
throw new Error(`unexpected`);
|
||||
}
|
||||
|
@ -137,7 +141,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
|||
' rem ',
|
||||
' !@# c',
|
||||
'\t\t!@#d'
|
||||
]), createBasicLinePreflightData(['//', 'rem', '!@#', '!@#']), 1, true, false, new TestLanguageConfigurationService());
|
||||
]), createBasicLinePreflightData(['//', 'rem', '!@#', '!@#']), 1, true, false, disposable.add(new TestLanguageConfigurationService()));
|
||||
if (!r.supported) {
|
||||
throw new Error(`unexpected`);
|
||||
}
|
||||
|
@ -167,6 +171,8 @@ suite('Editor Contrib - Line Comment Command', () => {
|
|||
assert.strictEqual(r.lines[1].commentStrLength, 4);
|
||||
assert.strictEqual(r.lines[2].commentStrLength, 4);
|
||||
assert.strictEqual(r.lines[3].commentStrLength, 3);
|
||||
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('_normalizeInsertionPoint', () => {
|
||||
|
@ -678,101 +684,105 @@ suite('Editor Contrib - Line Comment Command', () => {
|
|||
new Selection(1, 1, 1, 1)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
suite('ignoreEmptyLines false', () => {
|
||||
suite('ignoreEmptyLines false', () => {
|
||||
|
||||
const testLineCommentCommand = createTestCommandHelper(
|
||||
{ lineComment: '!@#', blockComment: ['<!@#', '#@!>'] },
|
||||
(accessor, sel) => new LineCommentCommand(accessor.get(ILanguageConfigurationService), sel, 4, Type.Toggle, true, false)
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const testLineCommentCommand = createTestCommandHelper(
|
||||
{ lineComment: '!@#', blockComment: ['<!@#', '#@!>'] },
|
||||
(accessor, sel) => new LineCommentCommand(accessor.get(ILanguageConfigurationService), sel, 4, Type.Toggle, true, false)
|
||||
);
|
||||
|
||||
test('does not ignore whitespace lines', () => {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'\tsome text',
|
||||
'\t ',
|
||||
'',
|
||||
'\tsome more text'
|
||||
],
|
||||
new Selection(4, 2, 1, 1),
|
||||
[
|
||||
'!@# \tsome text',
|
||||
'!@# \t ',
|
||||
'!@# ',
|
||||
'!@# \tsome more text'
|
||||
],
|
||||
new Selection(4, 6, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('does not ignore whitespace lines', () => {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'\tsome text',
|
||||
'\t ',
|
||||
'',
|
||||
'\tsome more text'
|
||||
],
|
||||
new Selection(4, 2, 1, 1),
|
||||
[
|
||||
'!@# \tsome text',
|
||||
'!@# \t ',
|
||||
'!@# ',
|
||||
'!@# \tsome more text'
|
||||
],
|
||||
new Selection(4, 6, 1, 5)
|
||||
);
|
||||
});
|
||||
test('removes its own', function () {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'\t!@# some text',
|
||||
'\t ',
|
||||
'\t\t!@# some more text'
|
||||
],
|
||||
new Selection(3, 2, 1, 1),
|
||||
[
|
||||
'\tsome text',
|
||||
'\t ',
|
||||
'\t\tsome more text'
|
||||
],
|
||||
new Selection(3, 2, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
test('removes its own', function () {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'\t!@# some text',
|
||||
'\t ',
|
||||
'\t\t!@# some more text'
|
||||
],
|
||||
new Selection(3, 2, 1, 1),
|
||||
[
|
||||
'\tsome text',
|
||||
'\t ',
|
||||
'\t\tsome more text'
|
||||
],
|
||||
new Selection(3, 2, 1, 1)
|
||||
);
|
||||
});
|
||||
test('works in only whitespace', function () {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'\t ',
|
||||
'\t',
|
||||
'\t\tsome more text'
|
||||
],
|
||||
new Selection(3, 1, 1, 1),
|
||||
[
|
||||
'\t!@# ',
|
||||
'\t!@# ',
|
||||
'\t\tsome more text'
|
||||
],
|
||||
new Selection(3, 1, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
test('works in only whitespace', function () {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'\t ',
|
||||
'\t',
|
||||
'\t\tsome more text'
|
||||
],
|
||||
new Selection(3, 1, 1, 1),
|
||||
[
|
||||
'\t!@# ',
|
||||
'\t!@# ',
|
||||
'\t\tsome more text'
|
||||
],
|
||||
new Selection(3, 1, 1, 1)
|
||||
);
|
||||
});
|
||||
test('comments single line', function () {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'some text',
|
||||
'\tsome more text'
|
||||
],
|
||||
new Selection(1, 1, 1, 1),
|
||||
[
|
||||
'!@# some text',
|
||||
'\tsome more text'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('comments single line', function () {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'some text',
|
||||
'\tsome more text'
|
||||
],
|
||||
new Selection(1, 1, 1, 1),
|
||||
[
|
||||
'!@# some text',
|
||||
'\tsome more text'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('detects indentation', function () {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'\tsome text',
|
||||
'\tsome more text'
|
||||
],
|
||||
new Selection(2, 2, 1, 1),
|
||||
[
|
||||
'\t!@# some text',
|
||||
'\t!@# some more text'
|
||||
],
|
||||
new Selection(2, 2, 1, 1)
|
||||
);
|
||||
});
|
||||
test('detects indentation', function () {
|
||||
testLineCommentCommand(
|
||||
[
|
||||
'\tsome text',
|
||||
'\tsome more text'
|
||||
],
|
||||
new Selection(2, 2, 1, 1),
|
||||
[
|
||||
'\t!@# some text',
|
||||
'\t!@# some more text'
|
||||
],
|
||||
new Selection(2, 2, 1, 1)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Contrib - Line Comment As Block Comment', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const testLineCommentCommand = createTestCommandHelper(
|
||||
{ lineComment: '', blockComment: ['(', ')'] },
|
||||
(accessor, sel) => new LineCommentCommand(accessor.get(ILanguageConfigurationService), sel, 4, Type.Toggle, true, true)
|
||||
|
@ -884,6 +894,8 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
|
|||
|
||||
suite('Editor Contrib - Line Comment As Block Comment 2', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const testLineCommentCommand = createTestCommandHelper(
|
||||
{ lineComment: null, blockComment: ['<!@#', '#@!>'] },
|
||||
(accessor, sel) => new LineCommentCommand(accessor.get(ILanguageConfigurationService), sel, 4, Type.Toggle, true, true)
|
||||
|
@ -1080,6 +1092,8 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => {
|
|||
|
||||
suite('Editor Contrib - Line Comment in mixed modes', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const OUTER_LANGUAGE_ID = 'outerMode';
|
||||
const INNER_LANGUAGE_ID = 'innerMode';
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { CoreEditingCommands, CoreNavigationCommands } from 'vs/editor/browser/coreCommands';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Handler } from 'vs/editor/common/editorCommon';
|
||||
|
@ -12,6 +13,8 @@ import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
|||
|
||||
suite('FindController', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const cursorUndoAction = new CursorUndo();
|
||||
|
||||
test('issue #82535: Edge case with cursorUndo', () => {
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { CodeEditorStateFlag, EditorState } from 'vs/editor/contrib/editorState/browser/editorState';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { CodeEditorStateFlag, EditorState } from 'vs/editor/contrib/editorState/browser/editorState';
|
||||
|
||||
interface IStubEditorState {
|
||||
model?: { uri?: URI; version?: number };
|
||||
|
@ -20,6 +21,8 @@ interface IStubEditorState {
|
|||
|
||||
suite('Editor Core - Editor State', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const allFlags = (
|
||||
CodeEditorStateFlag.Value
|
||||
| CodeEditorStateFlag.Selection
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { getSelectionSearchString } from 'vs/editor/contrib/find/browser/findController';
|
||||
|
@ -12,6 +13,8 @@ import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
|||
|
||||
suite('Find', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('search string at position', () => {
|
||||
withTestCodeEditor([
|
||||
'ABC DEF',
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import * as assert from 'assert';
|
||||
import { Delayer } from 'vs/base/common/async';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
|
@ -63,6 +64,9 @@ function executeAction(instantiationService: IInstantiationService, editor: ICod
|
|||
}
|
||||
|
||||
suite('FindController', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
let clipboardState = '';
|
||||
const serviceCollection = new ServiceCollection();
|
||||
serviceCollection.set(IStorageService, new InMemoryStorageService());
|
||||
|
@ -476,6 +480,9 @@ suite('FindController', () => {
|
|||
});
|
||||
|
||||
suite('FindController query options persistence', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const serviceCollection = new ServiceCollection();
|
||||
const storageService = new InMemoryStorageService();
|
||||
storageService.store('editor.isRegex', false, StorageScope.WORKSPACE, StorageTarget.USER);
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { buildReplaceStringWithCasePreserved } from 'vs/base/common/search';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { parseReplaceString, ReplacePattern, ReplacePiece } from 'vs/editor/contrib/find/browser/replacePattern';
|
||||
|
||||
suite('Replace Pattern test', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('parse replace string', () => {
|
||||
const testParse = (input: string, expectedPieces: ReplacePiece[]) => {
|
||||
const actual = parseReplaceString(input);
|
||||
|
|
|
@ -4,13 +4,17 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ContentHoverController } from 'vs/editor/contrib/hover/browser/contentHover';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ContentHoverController } from 'vs/editor/contrib/hover/browser/contentHover';
|
||||
import { IHoverPart } from 'vs/editor/contrib/hover/browser/hoverTypes';
|
||||
import { TestCodeEditorInstantiationOptions, withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
|
||||
suite('Content Hover', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #151235: Gitlens hover shows up in the wrong place', () => {
|
||||
const text = 'just some text';
|
||||
withTestCodeEditor(text, {}, (editor) => {
|
||||
|
|
|
@ -4,20 +4,21 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { MetadataConsts, StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { EncodedTokenizationResult, IState, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { NullState } from 'vs/editor/common/languages/nullTokenize';
|
||||
import { AutoIndentOnPaste, IndentationToSpacesCommand, IndentationToTabsCommand } from 'vs/editor/contrib/indentation/browser/indentation';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { javascriptIndentationRules } from 'vs/editor/test/common/modes/supports/javascriptIndentationRules';
|
||||
import { javascriptOnEnterRules } from 'vs/editor/test/common/modes/supports/javascriptOnEnterRules';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { EncodedTokenizationResult, IState, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { MetadataConsts, StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { NullState } from 'vs/editor/common/languages/nullTokenize';
|
||||
|
||||
function testIndentationToSpacesCommand(lines: string[], selection: Selection, tabSize: number, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, null, selection, (accessor, sel) => new IndentationToSpacesCommand(sel, tabSize), expectedLines, expectedSelection);
|
||||
|
@ -29,6 +30,8 @@ function testIndentationToTabsCommand(lines: string[], selection: Selection, tab
|
|||
|
||||
suite('Editor Contrib - Indentation to Spaces', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('single tabs only at start of line', function () {
|
||||
testIndentationToSpacesCommand(
|
||||
[
|
||||
|
@ -116,6 +119,8 @@ suite('Editor Contrib - Indentation to Spaces', () => {
|
|||
|
||||
suite('Editor Contrib - Indentation to Tabs', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('spaces only at start of line', function () {
|
||||
testIndentationToTabsCommand(
|
||||
[
|
||||
|
@ -208,6 +213,8 @@ suite('Editor Contrib - Auto Indent On Paste', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #119225: Do not add extra leading space when pasting JSDoc', () => {
|
||||
const languageId = 'leadingSpacePaste';
|
||||
const model = createTextModel("", languageId, {});
|
||||
|
@ -277,6 +284,8 @@ suite('Editor Contrib - Keep Indent On Paste', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #167299: Blank line removes indent', () => {
|
||||
const languageId = 'blankLineRemovesIndent';
|
||||
const model = createTextModel("", languageId, {});
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import type { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
|
@ -16,6 +17,9 @@ function executeAction(action: EditorAction, editor: ICodeEditor): void {
|
|||
}
|
||||
|
||||
suite('LineSelection', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('', () => {
|
||||
const LINE1 = ' \tMy First Line\t ';
|
||||
const LINE2 = '\tMy Second Line';
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { CopyLinesCommand } from 'vs/editor/contrib/linesOperations/browser/copyLinesCommand';
|
||||
import { DuplicateSelectionAction } from 'vs/editor/contrib/linesOperations/browser/linesOperations';
|
||||
|
@ -20,6 +21,8 @@ function testCopyLinesUpCommand(lines: string[], selection: Selection, expectedL
|
|||
|
||||
suite('Editor Contrib - Copy Lines Command', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('copy first line down', function () {
|
||||
testCopyLinesDownCommand(
|
||||
[
|
||||
|
@ -201,6 +204,8 @@ suite('Editor Contrib - Copy Lines Command', () => {
|
|||
|
||||
suite('Editor Contrib - Duplicate Selection', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const duplicateSelectionAction = new DuplicateSelectionAction();
|
||||
|
||||
function testDuplicateSelectionAction(lines: string[], selections: Selection[], expectedLines: string[], expectedSelections: Selection[]): void {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/coreCommands';
|
||||
import type { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
|
@ -27,6 +28,9 @@ function executeAction(action: EditorAction, editor: ICodeEditor): void {
|
|||
}
|
||||
|
||||
suite('Editor Contrib - Line Operations', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
suite('SortLinesAscendingAction', () => {
|
||||
test('should sort selected lines in ascending order', function () {
|
||||
withTestCodeEditor(
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { EditorAutoIndentStrategy } from 'vs/editor/common/config/editorOptions';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
|
@ -13,24 +14,46 @@ import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/browser/move
|
|||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService';
|
||||
|
||||
function testMoveLinesDownCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection, languageConfigurationService = new TestLanguageConfigurationService()): void {
|
||||
testCommand(lines, null, selection, (accessor, sel) => new MoveLinesCommand(sel, true, EditorAutoIndentStrategy.Advanced, languageConfigurationService), expectedLines, expectedSelection);
|
||||
function testMoveLinesDownCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection, languageConfigurationService?: ILanguageConfigurationService): void {
|
||||
const disposables = new DisposableStore();
|
||||
if (!languageConfigurationService) {
|
||||
languageConfigurationService = disposables.add(new TestLanguageConfigurationService());
|
||||
}
|
||||
testCommand(lines, null, selection, (accessor, sel) => new MoveLinesCommand(sel, true, EditorAutoIndentStrategy.Advanced, languageConfigurationService!), expectedLines, expectedSelection);
|
||||
disposables.dispose();
|
||||
}
|
||||
|
||||
function testMoveLinesUpCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection, languageConfigurationService = new TestLanguageConfigurationService()): void {
|
||||
testCommand(lines, null, selection, (accessor, sel) => new MoveLinesCommand(sel, false, EditorAutoIndentStrategy.Advanced, languageConfigurationService), expectedLines, expectedSelection);
|
||||
function testMoveLinesUpCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection, languageConfigurationService?: ILanguageConfigurationService): void {
|
||||
const disposables = new DisposableStore();
|
||||
if (!languageConfigurationService) {
|
||||
languageConfigurationService = disposables.add(new TestLanguageConfigurationService());
|
||||
}
|
||||
testCommand(lines, null, selection, (accessor, sel) => new MoveLinesCommand(sel, false, EditorAutoIndentStrategy.Advanced, languageConfigurationService!), expectedLines, expectedSelection);
|
||||
disposables.dispose();
|
||||
}
|
||||
|
||||
function testMoveLinesDownWithIndentCommand(languageId: string, lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection, languageConfigurationService = new TestLanguageConfigurationService()): void {
|
||||
testCommand(lines, languageId, selection, (accessor, sel) => new MoveLinesCommand(sel, true, EditorAutoIndentStrategy.Full, languageConfigurationService), expectedLines, expectedSelection);
|
||||
function testMoveLinesDownWithIndentCommand(languageId: string, lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection, languageConfigurationService?: ILanguageConfigurationService): void {
|
||||
const disposables = new DisposableStore();
|
||||
if (!languageConfigurationService) {
|
||||
languageConfigurationService = disposables.add(new TestLanguageConfigurationService());
|
||||
}
|
||||
testCommand(lines, languageId, selection, (accessor, sel) => new MoveLinesCommand(sel, true, EditorAutoIndentStrategy.Full, languageConfigurationService!), expectedLines, expectedSelection);
|
||||
disposables.dispose();
|
||||
}
|
||||
|
||||
function testMoveLinesUpWithIndentCommand(languageId: string, lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection, languageConfigurationService = new TestLanguageConfigurationService()): void {
|
||||
testCommand(lines, languageId, selection, (accessor, sel) => new MoveLinesCommand(sel, false, EditorAutoIndentStrategy.Full, languageConfigurationService), expectedLines, expectedSelection);
|
||||
function testMoveLinesUpWithIndentCommand(languageId: string, lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection, languageConfigurationService?: ILanguageConfigurationService): void {
|
||||
const disposables = new DisposableStore();
|
||||
if (!languageConfigurationService) {
|
||||
languageConfigurationService = disposables.add(new TestLanguageConfigurationService());
|
||||
}
|
||||
testCommand(lines, languageId, selection, (accessor, sel) => new MoveLinesCommand(sel, false, EditorAutoIndentStrategy.Full, languageConfigurationService!), expectedLines, expectedSelection);
|
||||
disposables.dispose();
|
||||
}
|
||||
|
||||
suite('Editor Contrib - Move Lines Command', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('move first up / last down disabled', function () {
|
||||
testMoveLinesUpCommand(
|
||||
[
|
||||
|
@ -277,6 +300,9 @@ class IndentRulesMode extends Disposable {
|
|||
}
|
||||
|
||||
suite('Editor contrib - Move Lines Command honors Indentation Rules', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const indentRules = {
|
||||
decreaseIndentPattern: /^\s*((?!\S.*\/[*]).*[*]\/\s*)?[})\]]|^\s*(case\b.*|default):\s*(\/\/.*|\/[*].*[*]\/\s*)?$/,
|
||||
increaseIndentPattern: /(\{[^}"'`]*|\([^)"']*|\[[^\]"']*|^\s*(\{\}|\(\)|\[\]|(case\b.*|default):))\s*(\/\/.*|\/[*].*[*]\/\s*)?$/,
|
||||
|
@ -309,6 +335,7 @@ suite('Editor contrib - Move Lines Command honors Indentation Rules', () => {
|
|||
|
||||
mode.dispose();
|
||||
languageService.dispose();
|
||||
languageConfigurationService.dispose();
|
||||
});
|
||||
|
||||
// https://github.com/microsoft/vscode/issues/28552#issuecomment-307867717
|
||||
|
@ -342,6 +369,7 @@ suite('Editor contrib - Move Lines Command honors Indentation Rules', () => {
|
|||
|
||||
mode.dispose();
|
||||
languageService.dispose();
|
||||
languageConfigurationService.dispose();
|
||||
});
|
||||
|
||||
|
||||
|
@ -390,6 +418,8 @@ class EnterRulesMode extends Disposable {
|
|||
|
||||
suite('Editor - contrib - Move Lines Command honors onEnter Rules', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #54829. move block across block', () => {
|
||||
const languageService = new LanguageService();
|
||||
const languageConfigurationService = new TestLanguageConfigurationService();
|
||||
|
@ -425,5 +455,6 @@ suite('Editor - contrib - Move Lines Command honors onEnter Rules', () => {
|
|||
|
||||
mode.dispose();
|
||||
languageService.dispose();
|
||||
languageConfigurationService.dispose();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/browser/sortLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
|
@ -17,6 +18,8 @@ function testSortLinesDescendingCommand(lines: string[], selection: Selection, e
|
|||
|
||||
suite('Editor Contrib - Sort Lines Command', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('no op unless at least two lines selected 1', function () {
|
||||
testSortLinesAscendingCommand(
|
||||
[
|
||||
|
|
|
@ -6,21 +6,22 @@
|
|||
import * as assert from 'assert';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { runWithFakedTimers } from 'vs/base/test/common/timeTravelScheduler';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/coreCommands';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { Handler } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/core/wordHelper';
|
||||
import { Handler } from 'vs/editor/common/editorCommon';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { LinkedEditingContribution } from 'vs/editor/contrib/linkedEditing/browser/linkedEditing';
|
||||
import { createCodeEditorServices, instantiateTestCodeEditor, ITestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { DeleteWordLeft } from 'vs/editor/contrib/wordOperations/browser/wordOperations';
|
||||
import { DeleteAllLeftAction } from 'vs/editor/contrib/linesOperations/browser/linesOperations';
|
||||
import { runWithFakedTimers } from 'vs/base/test/common/timeTravelScheduler';
|
||||
import { LinkedEditingContribution } from 'vs/editor/contrib/linkedEditing/browser/linkedEditing';
|
||||
import { DeleteWordLeft } from 'vs/editor/contrib/wordOperations/browser/wordOperations';
|
||||
import { ITestCodeEditor, createCodeEditorServices, instantiateTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
|
||||
const mockFile = URI.parse('test:somefile.ttt');
|
||||
const mockFileSelector = { scheme: 'test' };
|
||||
|
@ -57,6 +58,8 @@ suite('linked editing', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function createMockEditor(text: string | string[]): ITestCodeEditor {
|
||||
const model = disposables.add(instantiateTextModel(instantiationService, typeof text === 'string' ? text : text.join('\n'), languageId, undefined, mockFile));
|
||||
const editor = disposables.add(instantiateTestCodeEditor(instantiationService, model));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Handler } from 'vs/editor/common/editorCommon';
|
||||
|
@ -15,6 +16,8 @@ import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/com
|
|||
|
||||
suite('Multicursor', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #26393: Multiple cursors + Word wrap', () => {
|
||||
withTestCodeEditor([
|
||||
'a'.repeat(20),
|
||||
|
|
|
@ -4,35 +4,36 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ModelService } from 'vs/editor/common/services/modelService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { TestColorTheme, TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { DocumentSemanticTokensProvider, SemanticTokens, SemanticTokensEdits, SemanticTokensLegend } from 'vs/editor/common/languages';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Barrier, timeout } from 'vs/base/common/async';
|
||||
import { LanguageService } from 'vs/editor/common/services/languageService';
|
||||
import { ColorScheme } from 'vs/platform/theme/common/theme';
|
||||
import { IModelService } from 'vs/editor/common/services/model';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { TestTextResourcePropertiesService } from 'vs/editor/test/common/services/testTextResourcePropertiesService';
|
||||
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService';
|
||||
import { getDocumentSemanticTokens, isSemanticTokens } from 'vs/editor/contrib/semanticTokens/common/getSemanticTokens';
|
||||
import { LanguageFeatureDebounceService } from 'vs/editor/common/services/languageFeatureDebounce';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { runWithFakedTimers } from 'vs/base/test/common/timeTravelScheduler';
|
||||
import { LanguageFeaturesService } from 'vs/editor/common/services/languageFeaturesService';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { DocumentSemanticTokensProvider, SemanticTokens, SemanticTokensEdits, SemanticTokensLegend } from 'vs/editor/common/languages';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { LanguageFeatureDebounceService } from 'vs/editor/common/services/languageFeatureDebounce';
|
||||
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
|
||||
import { LanguageFeaturesService } from 'vs/editor/common/services/languageFeaturesService';
|
||||
import { LanguageService } from 'vs/editor/common/services/languageService';
|
||||
import { IModelService } from 'vs/editor/common/services/model';
|
||||
import { ModelService } from 'vs/editor/common/services/modelService';
|
||||
import { SemanticTokensStylingService } from 'vs/editor/common/services/semanticTokensStylingService';
|
||||
import { DocumentSemanticTokensFeature } from 'vs/editor/contrib/semanticTokens/browser/documentSemanticTokens';
|
||||
import { getDocumentSemanticTokens, isSemanticTokens } from 'vs/editor/contrib/semanticTokens/common/getSemanticTokens';
|
||||
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService';
|
||||
import { TestTextResourcePropertiesService } from 'vs/editor/test/common/services/testTextResourcePropertiesService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { ColorScheme } from 'vs/platform/theme/common/theme';
|
||||
import { TestColorTheme, TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
|
||||
suite('ModelSemanticColoring', () => {
|
||||
|
||||
|
@ -67,6 +68,8 @@ suite('ModelSemanticColoring', () => {
|
|||
disposables.clear();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('DocumentSemanticTokens should be fetched when the result is empty if there are pending changes', async () => {
|
||||
await runWithFakedTimers({}, async () => {
|
||||
|
||||
|
|
|
@ -7,14 +7,17 @@ import * as assert from 'assert';
|
|||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { canceled } from 'vs/base/common/errors';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { LanguageFeatureRegistry } from 'vs/editor/common/languageFeatureRegistry';
|
||||
import { DocumentSemanticTokensProvider, ProviderResult, SemanticTokens, SemanticTokensEdits, SemanticTokensLegend } from 'vs/editor/common/languages';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { getDocumentSemanticTokens } from 'vs/editor/contrib/semanticTokens/common/getSemanticTokens';
|
||||
import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { LanguageFeatureRegistry } from 'vs/editor/common/languageFeatureRegistry';
|
||||
|
||||
suite('getSemanticTokens', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #136540: semantic highlighting flickers', async () => {
|
||||
const disposables = new DisposableStore();
|
||||
const registry = new LanguageFeatureRegistry<DocumentSemanticTokensProvider>();
|
||||
|
|
|
@ -4,20 +4,21 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/coreCommands';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
import { deserializePipePositions, serializePipePositions, testRepeatedActionAndExtractPositions } from 'vs/editor/contrib/wordOperations/test/browser/wordTestUtils';
|
||||
import { CursorWordAccessibilityLeft, CursorWordAccessibilityLeftSelect, CursorWordAccessibilityRight, CursorWordAccessibilityRightSelect, CursorWordEndLeft, CursorWordEndLeftSelect, CursorWordEndRight, CursorWordEndRightSelect, CursorWordLeft, CursorWordLeftSelect, CursorWordRight, CursorWordRightSelect, CursorWordStartLeft, CursorWordStartLeftSelect, CursorWordStartRight, CursorWordStartRightSelect, DeleteInsideWord, DeleteWordEndLeft, DeleteWordEndRight, DeleteWordLeft, DeleteWordRight, DeleteWordStartLeft, DeleteWordStartRight } from 'vs/editor/contrib/wordOperations/browser/wordOperations';
|
||||
import { deserializePipePositions, serializePipePositions, testRepeatedActionAndExtractPositions } from 'vs/editor/contrib/wordOperations/test/browser/wordTestUtils';
|
||||
import { createCodeEditorServices, instantiateTestCodeEditor, withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
|
||||
suite('WordOperations', () => {
|
||||
|
||||
|
@ -61,6 +62,8 @@ suite('WordOperations', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function runEditorCommand(editor: ICodeEditor, command: EditorCommand): void {
|
||||
instantiationService.invokeFunction((accessor) => {
|
||||
command.runEditorCommand(accessor, editor, null);
|
||||
|
|
|
@ -4,16 +4,20 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { deserializePipePositions, serializePipePositions, testRepeatedActionAndExtractPositions } from 'vs/editor/contrib/wordOperations/test/browser/wordTestUtils';
|
||||
import { StaticServiceAccessor } from 'vs/editor/contrib/wordPartOperations/test/browser/utils';
|
||||
import { CursorWordPartLeft, CursorWordPartLeftSelect, CursorWordPartRight, CursorWordPartRightSelect, DeleteWordPartLeft, DeleteWordPartRight } from 'vs/editor/contrib/wordPartOperations/browser/wordPartOperations';
|
||||
import { StaticServiceAccessor } from 'vs/editor/contrib/wordPartOperations/test/browser/utils';
|
||||
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService';
|
||||
|
||||
suite('WordPartOperations', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const _deleteWordPartLeft = new DeleteWordPartLeft();
|
||||
const _deleteWordPartRight = new DeleteWordPartRight();
|
||||
const _cursorWordPartLeft = new CursorWordPartLeft();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* using regular expressions.
|
||||
*/
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as languages from 'vs/editor/common/languages';
|
||||
import { NullState, nullTokenizeEncoded, nullTokenize } from 'vs/editor/common/languages/nullTokenize';
|
||||
import { TokenTheme } from 'vs/editor/common/languages/supports/tokenization';
|
||||
|
@ -387,7 +387,7 @@ class MonarchModernTokensCollector implements IMonarchTokensCollector {
|
|||
|
||||
export type ILoadStatus = { loaded: true } | { loaded: false; promise: Promise<void> };
|
||||
|
||||
export class MonarchTokenizer implements languages.ITokenizationSupport, IDisposable {
|
||||
export class MonarchTokenizer extends Disposable implements languages.ITokenizationSupport, IDisposable {
|
||||
|
||||
private readonly _languageService: ILanguageService;
|
||||
private readonly _standaloneThemeService: IStandaloneThemeService;
|
||||
|
@ -395,10 +395,10 @@ export class MonarchTokenizer implements languages.ITokenizationSupport, IDispos
|
|||
private readonly _lexer: monarchCommon.ILexer;
|
||||
private readonly _embeddedLanguages: { [languageId: string]: boolean };
|
||||
public embeddedLoaded: Promise<void>;
|
||||
private readonly _tokenizationRegistryListener: IDisposable;
|
||||
private _maxTokenizationLineLength: number;
|
||||
|
||||
constructor(languageService: ILanguageService, standaloneThemeService: IStandaloneThemeService, languageId: string, lexer: monarchCommon.ILexer, @IConfigurationService private readonly _configurationService: IConfigurationService) {
|
||||
super();
|
||||
this._languageService = languageService;
|
||||
this._standaloneThemeService = standaloneThemeService;
|
||||
this._languageId = languageId;
|
||||
|
@ -408,7 +408,7 @@ export class MonarchTokenizer implements languages.ITokenizationSupport, IDispos
|
|||
|
||||
// Set up listening for embedded modes
|
||||
let emitting = false;
|
||||
this._tokenizationRegistryListener = languages.TokenizationRegistry.onDidChange((e) => {
|
||||
this._register(languages.TokenizationRegistry.onDidChange((e) => {
|
||||
if (emitting) {
|
||||
return;
|
||||
}
|
||||
|
@ -425,21 +425,17 @@ export class MonarchTokenizer implements languages.ITokenizationSupport, IDispos
|
|||
languages.TokenizationRegistry.handleChange([this._languageId]);
|
||||
emitting = false;
|
||||
}
|
||||
});
|
||||
}));
|
||||
this._maxTokenizationLineLength = this._configurationService.getValue<number>('editor.maxTokenizationLineLength', {
|
||||
overrideIdentifier: this._languageId
|
||||
});
|
||||
this._configurationService.onDidChangeConfiguration(e => {
|
||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('editor.maxTokenizationLineLength')) {
|
||||
this._maxTokenizationLineLength = this._configurationService.getValue<number>('editor.maxTokenizationLineLength', {
|
||||
overrideIdentifier: this._languageId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._tokenizationRegistryListener.dispose();
|
||||
}));
|
||||
}
|
||||
|
||||
public getLoadStatus(): ILoadStatus {
|
||||
|
|
|
@ -4,18 +4,21 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { LanguageService } from 'vs/editor/common/services/languageService';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { MonarchTokenizer } from 'vs/editor/standalone/common/monarch/monarchLexer';
|
||||
import { compile } from 'vs/editor/standalone/common/monarch/monarchCompile';
|
||||
import { Token, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { IMonarchLanguage } from 'vs/editor/standalone/common/monarch/monarchTypes';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Token, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { LanguageService } from 'vs/editor/common/services/languageService';
|
||||
import { StandaloneConfigurationService } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import { compile } from 'vs/editor/standalone/common/monarch/monarchCompile';
|
||||
import { MonarchTokenizer } from 'vs/editor/standalone/common/monarch/monarchLexer';
|
||||
import { IMonarchLanguage } from 'vs/editor/standalone/common/monarch/monarchTypes';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
suite('Monarch', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function createMonarchTokenizer(languageService: ILanguageService, languageId: string, language: IMonarchLanguage, configurationService: IConfigurationService): MonarchTokenizer {
|
||||
return new MonarchTokenizer(languageService, null!, languageId, compile(languageId, language), configurationService);
|
||||
}
|
||||
|
@ -36,15 +39,15 @@ suite('Monarch', () => {
|
|||
const languageService = disposables.add(new LanguageService());
|
||||
const configurationService = new StandaloneConfigurationService();
|
||||
disposables.add(languageService.registerLanguage({ id: 'sql' }));
|
||||
disposables.add(TokenizationRegistry.register('sql', createMonarchTokenizer(languageService, 'sql', {
|
||||
disposables.add(TokenizationRegistry.register('sql', disposables.add(createMonarchTokenizer(languageService, 'sql', {
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/./, 'token']
|
||||
]
|
||||
}
|
||||
}, configurationService)));
|
||||
}, configurationService))));
|
||||
const SQL_QUERY_START = '(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|WITH)';
|
||||
const tokenizer = createMonarchTokenizer(languageService, 'test1', {
|
||||
const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test1', {
|
||||
tokenizer: {
|
||||
root: [
|
||||
[`(\"\"\")${SQL_QUERY_START}`, [{ 'token': 'string.quote', }, { token: '@rematch', next: '@endStringWithSQL', nextEmbedded: 'sql', },]],
|
||||
|
@ -66,7 +69,7 @@ suite('Monarch', () => {
|
|||
],
|
||||
endStringWithSQL: [[/"""/, { token: 'string.quote', next: '@popall', nextEmbedded: '@pop', },]],
|
||||
}
|
||||
}, configurationService);
|
||||
}, configurationService));
|
||||
|
||||
const lines = [
|
||||
`mysql_query("""SELECT * FROM table_name WHERE ds = '<DATEID>'""")`,
|
||||
|
@ -109,9 +112,10 @@ suite('Monarch', () => {
|
|||
});
|
||||
|
||||
test('microsoft/monaco-editor#1235: Empty Line Handling', () => {
|
||||
const disposables = new DisposableStore();
|
||||
const configurationService = new StandaloneConfigurationService();
|
||||
const languageService = new LanguageService();
|
||||
const tokenizer = createMonarchTokenizer(languageService, 'test', {
|
||||
const languageService = disposables.add(new LanguageService());
|
||||
const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test', {
|
||||
tokenizer: {
|
||||
root: [
|
||||
{ include: '@comments' },
|
||||
|
@ -129,7 +133,7 @@ suite('Monarch', () => {
|
|||
// No possible rule to detect an empty line and @pop?
|
||||
],
|
||||
},
|
||||
}, configurationService);
|
||||
}, configurationService));
|
||||
|
||||
const lines = [
|
||||
`// This comment \\`,
|
||||
|
@ -162,14 +166,15 @@ suite('Monarch', () => {
|
|||
[],
|
||||
[new Token(0, 'source.test', 'test')]
|
||||
]);
|
||||
languageService.dispose();
|
||||
|
||||
disposables.dispose();
|
||||
});
|
||||
|
||||
test('microsoft/monaco-editor#2265: Exit a state at end of line', () => {
|
||||
const disposables = new DisposableStore();
|
||||
const configurationService = new StandaloneConfigurationService();
|
||||
const languageService = new LanguageService();
|
||||
const tokenizer = createMonarchTokenizer(languageService, 'test', {
|
||||
const languageService = disposables.add(new LanguageService());
|
||||
const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test', {
|
||||
includeLF: true,
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
@ -184,7 +189,7 @@ suite('Monarch', () => {
|
|||
[/[^\d]+/, '']
|
||||
]
|
||||
}
|
||||
}, configurationService);
|
||||
}, configurationService));
|
||||
|
||||
const lines = [
|
||||
`PRINT 10 * 20`,
|
||||
|
@ -212,14 +217,16 @@ suite('Monarch', () => {
|
|||
new Token(18, 'number.test', 'test'),
|
||||
]
|
||||
]);
|
||||
languageService.dispose();
|
||||
|
||||
disposables.dispose();
|
||||
});
|
||||
|
||||
test('issue #115662: monarchCompile function need an extra option which can control replacement', () => {
|
||||
const disposables = new DisposableStore();
|
||||
const configurationService = new StandaloneConfigurationService();
|
||||
const languageService = new LanguageService();
|
||||
const languageService = disposables.add(new LanguageService());
|
||||
|
||||
const tokenizer1 = createMonarchTokenizer(languageService, 'test', {
|
||||
const tokenizer1 = disposables.add(createMonarchTokenizer(languageService, 'test', {
|
||||
ignoreCase: false,
|
||||
uselessReplaceKey1: '@uselessReplaceKey2',
|
||||
uselessReplaceKey2: '@uselessReplaceKey3',
|
||||
|
@ -236,9 +243,9 @@ suite('Monarch', () => {
|
|||
},
|
||||
],
|
||||
},
|
||||
}, configurationService);
|
||||
}, configurationService));
|
||||
|
||||
const tokenizer2 = createMonarchTokenizer(languageService, 'test', {
|
||||
const tokenizer2 = disposables.add(createMonarchTokenizer(languageService, 'test', {
|
||||
ignoreCase: false,
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
@ -248,7 +255,7 @@ suite('Monarch', () => {
|
|||
},
|
||||
],
|
||||
},
|
||||
}, configurationService);
|
||||
}, configurationService));
|
||||
|
||||
const lines = [
|
||||
`@ham`
|
||||
|
@ -267,14 +274,16 @@ suite('Monarch', () => {
|
|||
new Token(0, 'ham.test', 'test'),
|
||||
]
|
||||
]);
|
||||
languageService.dispose();
|
||||
|
||||
disposables.dispose();
|
||||
});
|
||||
|
||||
test('microsoft/monaco-editor#2424: Allow to target @@', () => {
|
||||
const disposables = new DisposableStore();
|
||||
const configurationService = new StandaloneConfigurationService();
|
||||
const languageService = new LanguageService();
|
||||
const languageService = disposables.add(new LanguageService());
|
||||
|
||||
const tokenizer = createMonarchTokenizer(languageService, 'test', {
|
||||
const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test', {
|
||||
ignoreCase: false,
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
@ -284,7 +293,7 @@ suite('Monarch', () => {
|
|||
},
|
||||
],
|
||||
},
|
||||
}, configurationService);
|
||||
}, configurationService));
|
||||
|
||||
const lines = [
|
||||
`@@`
|
||||
|
@ -296,17 +305,20 @@ suite('Monarch', () => {
|
|||
new Token(0, 'ham.test', 'test'),
|
||||
]
|
||||
]);
|
||||
languageService.dispose();
|
||||
|
||||
disposables.dispose();
|
||||
});
|
||||
|
||||
test('microsoft/monaco-editor#3025: Check maxTokenizationLineLength before tokenizing', async () => {
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
const configurationService = new StandaloneConfigurationService();
|
||||
const languageService = new LanguageService();
|
||||
const languageService = disposables.add(new LanguageService());
|
||||
|
||||
// Set maxTokenizationLineLength to 4 so that "ham" works but "hamham" would fail
|
||||
await configurationService.updateValue('editor.maxTokenizationLineLength', 4);
|
||||
|
||||
const tokenizer = createMonarchTokenizer(languageService, 'test', {
|
||||
const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test', {
|
||||
tokenizer: {
|
||||
root: [
|
||||
{
|
||||
|
@ -315,7 +327,7 @@ suite('Monarch', () => {
|
|||
},
|
||||
],
|
||||
},
|
||||
}, configurationService);
|
||||
}, configurationService));
|
||||
|
||||
const lines = [
|
||||
'ham', // length 3, should be tokenized
|
||||
|
@ -330,7 +342,8 @@ suite('Monarch', () => {
|
|||
new Token(0, '', 'test')
|
||||
]
|
||||
]);
|
||||
languageService.dispose();
|
||||
|
||||
disposables.dispose();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -7,8 +7,9 @@ import * as assert from 'assert';
|
|||
import { Color } from 'vs/base/common/color';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Token, IState } from 'vs/editor/common/languages';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { LanguageId, MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { IState, Token } from 'vs/editor/common/languages';
|
||||
import { TokenTheme } from 'vs/editor/common/languages/supports/tokenization';
|
||||
import { LanguageService } from 'vs/editor/common/services/languageService';
|
||||
import { ILineTokens, IToken, TokenizationSupportAdapter, TokensProvider } from 'vs/editor/standalone/browser/standaloneLanguages';
|
||||
|
@ -16,10 +17,12 @@ import { IStandaloneTheme, IStandaloneThemeData, IStandaloneThemeService } from
|
|||
import { UnthemedProductIconTheme } from 'vs/platform/theme/browser/iconsStyleSheet';
|
||||
import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { ColorScheme } from 'vs/platform/theme/common/theme';
|
||||
import { IFileIconTheme, IColorTheme, ITokenStyle, IProductIconTheme } from 'vs/platform/theme/common/themeService';
|
||||
import { IColorTheme, IFileIconTheme, IProductIconTheme, ITokenStyle } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
suite('TokenizationSupport2Adapter', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const languageId = 'tttt';
|
||||
// const tokenMetadata = (LanguageId.PlainText << MetadataConsts.LANGUAGEID_OFFSET);
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { StandaloneConfigurationService, StandaloneNotificationService, StandaloneCommandService, StandaloneKeybindingService } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { StandaloneCodeEditorService } from 'vs/editor/standalone/browser/standaloneCodeEditorService';
|
||||
import { StandaloneCommandService, StandaloneConfigurationService, StandaloneKeybindingService, StandaloneNotificationService } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import { StandaloneThemeService } from 'vs/editor/standalone/browser/standaloneThemeService';
|
||||
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
|
@ -25,20 +26,21 @@ suite('StandaloneKeybindingService', () => {
|
|||
|
||||
test('issue microsoft/monaco-editor#167', () => {
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
const serviceCollection = new ServiceCollection();
|
||||
const instantiationService = new InstantiationService(serviceCollection, true);
|
||||
const configurationService = new StandaloneConfigurationService();
|
||||
const contextKeyService = new ContextKeyService(configurationService);
|
||||
const contextKeyService = disposables.add(new ContextKeyService(configurationService));
|
||||
const commandService = new StandaloneCommandService(instantiationService);
|
||||
const notificationService = new StandaloneNotificationService();
|
||||
const standaloneThemeService = new StandaloneThemeService();
|
||||
const codeEditorService = new StandaloneCodeEditorService(contextKeyService, standaloneThemeService);
|
||||
const keybindingService = new TestStandaloneKeybindingService(contextKeyService, commandService, NullTelemetryService, notificationService, new NullLogService(), codeEditorService);
|
||||
const standaloneThemeService = disposables.add(new StandaloneThemeService());
|
||||
const codeEditorService = disposables.add(new StandaloneCodeEditorService(contextKeyService, standaloneThemeService));
|
||||
const keybindingService = disposables.add(new TestStandaloneKeybindingService(contextKeyService, commandService, NullTelemetryService, notificationService, new NullLogService(), codeEditorService));
|
||||
|
||||
let commandInvoked = false;
|
||||
keybindingService.addDynamicKeybinding('testCommand', KeyCode.F9, () => {
|
||||
disposables.add(keybindingService.addDynamicKeybinding('testCommand', KeyCode.F9, () => {
|
||||
commandInvoked = true;
|
||||
}, undefined);
|
||||
}, undefined));
|
||||
|
||||
keybindingService.testDispatch({
|
||||
_standardKeyboardEventBrand: true,
|
||||
|
@ -52,5 +54,7 @@ suite('StandaloneKeybindingService', () => {
|
|||
});
|
||||
|
||||
assert.ok(commandInvoked, 'command invoked');
|
||||
|
||||
disposables.dispose();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,18 +4,19 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ShiftCommand } from 'vs/editor/common/commands/shiftCommand';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { getEditOperation, testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { withEditorModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { javascriptOnEnterRules } from 'vs/editor/test/common/modes/supports/javascriptOnEnterRules';
|
||||
import { EditorAutoIndentStrategy } from 'vs/editor/common/config/editorOptions';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { getEditOperation, testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { javascriptOnEnterRules } from 'vs/editor/test/common/modes/supports/javascriptOnEnterRules';
|
||||
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService';
|
||||
import { withEditorModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
/**
|
||||
|
@ -82,6 +83,8 @@ function prepareDocBlockCommentLanguage(accessor: ServicesAccessor, disposables:
|
|||
|
||||
suite('Editor Commands - ShiftCommand', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
// --------- shift
|
||||
|
||||
test('Bug 9503: Shifting without any selection', () => {
|
||||
|
@ -683,7 +686,7 @@ suite('Editor Commands - ShiftCommand', () => {
|
|||
insertSpaces: true,
|
||||
useTabStops: false,
|
||||
autoIndent: EditorAutoIndentStrategy.Full,
|
||||
}, new TestLanguageConfigurationService()),
|
||||
}, accessor.get(ILanguageConfigurationService)),
|
||||
[
|
||||
' Written | Numeric',
|
||||
' one | 1',
|
||||
|
@ -729,7 +732,7 @@ suite('Editor Commands - ShiftCommand', () => {
|
|||
insertSpaces: true,
|
||||
useTabStops: false,
|
||||
autoIndent: EditorAutoIndentStrategy.Full,
|
||||
}, new TestLanguageConfigurationService()),
|
||||
}, accessor.get(ILanguageConfigurationService)),
|
||||
[
|
||||
' Written | Numeric',
|
||||
' one | 1',
|
||||
|
@ -775,7 +778,7 @@ suite('Editor Commands - ShiftCommand', () => {
|
|||
insertSpaces: false,
|
||||
useTabStops: false,
|
||||
autoIndent: EditorAutoIndentStrategy.Full,
|
||||
}, new TestLanguageConfigurationService()),
|
||||
}, accessor.get(ILanguageConfigurationService)),
|
||||
[
|
||||
' Written | Numeric',
|
||||
' one | 1',
|
||||
|
@ -821,7 +824,7 @@ suite('Editor Commands - ShiftCommand', () => {
|
|||
insertSpaces: true,
|
||||
useTabStops: false,
|
||||
autoIndent: EditorAutoIndentStrategy.Full,
|
||||
}, new TestLanguageConfigurationService()),
|
||||
}, accessor.get(ILanguageConfigurationService)),
|
||||
[
|
||||
' Written | Numeric',
|
||||
' one | 1',
|
||||
|
@ -856,7 +859,7 @@ suite('Editor Commands - ShiftCommand', () => {
|
|||
insertSpaces: false,
|
||||
useTabStops: true,
|
||||
autoIndent: EditorAutoIndentStrategy.Full,
|
||||
}, new TestLanguageConfigurationService()),
|
||||
}, accessor.get(ILanguageConfigurationService)),
|
||||
[
|
||||
'\tHello world!',
|
||||
'another line'
|
||||
|
@ -960,6 +963,7 @@ suite('Editor Commands - ShiftCommand', () => {
|
|||
|
||||
function _assertUnshiftCommand(tabSize: number, indentSize: number, insertSpaces: boolean, text: string[], expected: ISingleEditOperation[]): void {
|
||||
return withEditorModel(text, (model) => {
|
||||
const testLanguageConfigurationService = new TestLanguageConfigurationService();
|
||||
const op = new ShiftCommand(new Selection(1, 1, text.length + 1, 1), {
|
||||
isUnshift: true,
|
||||
tabSize: tabSize,
|
||||
|
@ -967,14 +971,16 @@ suite('Editor Commands - ShiftCommand', () => {
|
|||
insertSpaces: insertSpaces,
|
||||
useTabStops: true,
|
||||
autoIndent: EditorAutoIndentStrategy.Full,
|
||||
}, new TestLanguageConfigurationService());
|
||||
}, testLanguageConfigurationService);
|
||||
const actual = getEditOperation(model, op);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
testLanguageConfigurationService.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
function _assertShiftCommand(tabSize: number, indentSize: number, insertSpaces: boolean, text: string[], expected: ISingleEditOperation[]): void {
|
||||
return withEditorModel(text, (model) => {
|
||||
const testLanguageConfigurationService = new TestLanguageConfigurationService();
|
||||
const op = new ShiftCommand(new Selection(1, 1, text.length + 1, 1), {
|
||||
isUnshift: false,
|
||||
tabSize: tabSize,
|
||||
|
@ -982,9 +988,10 @@ suite('Editor Commands - ShiftCommand', () => {
|
|||
insertSpaces: insertSpaces,
|
||||
useTabStops: true,
|
||||
autoIndent: EditorAutoIndentStrategy.Full,
|
||||
}, new TestLanguageConfigurationService());
|
||||
}, testLanguageConfigurationService);
|
||||
const actual = getEditOperation(model, op);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
testLanguageConfigurationService.dispose();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { EditOperation, ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
|
@ -28,6 +29,8 @@ function testCommand(lines: string[], selections: Selection[], edits: ISingleEdi
|
|||
|
||||
suite('Editor Side Editing - collapsed selection', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('replace at selection', () => {
|
||||
testCommand(
|
||||
[
|
||||
|
@ -186,6 +189,8 @@ suite('Editor Side Editing - collapsed selection', () => {
|
|||
|
||||
suite('SideEditing', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const LINES = [
|
||||
'My First Line',
|
||||
'My Second Line',
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { TrimTrailingWhitespaceCommand, trimTrailingWhitespace } from 'vs/editor/common/commands/trimTrailingWhitespaceCommand';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
|
@ -50,6 +51,8 @@ function assertTrimTrailingWhitespace(text: string[], cursors: Position[], expec
|
|||
|
||||
suite('Editor Commands - Trim Trailing Whitespace Command', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('remove trailing whitespace', function () {
|
||||
assertTrimTrailingWhitespaceCommand([''], []);
|
||||
assertTrimTrailingWhitespaceCommand(['text'], []);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { IEnvConfiguration } from 'vs/editor/browser/config/editorConfiguration';
|
||||
import { migrateOptions } from 'vs/editor/browser/config/migrateOptions';
|
||||
import { ConfigurationChangedEvent, EditorOption, IEditorHoverOptions, IQuickSuggestionsOptions } from 'vs/editor/common/config/editorOptions';
|
||||
|
@ -12,6 +13,9 @@ import { TestConfiguration } from 'vs/editor/test/browser/config/testConfigurati
|
|||
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
suite('Common Editor Config', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Zoom Level', () => {
|
||||
|
||||
//Zoom levels are defined to go between -5, 20 inclusive
|
||||
|
@ -77,6 +81,7 @@ suite('Common Editor Config', () => {
|
|||
test('wordWrap default', () => {
|
||||
const config = new TestWrappingConfiguration({});
|
||||
assertWrapping(config, false, -1);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap compat false', () => {
|
||||
|
@ -84,6 +89,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrap: <any>false
|
||||
});
|
||||
assertWrapping(config, false, -1);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap compat true', () => {
|
||||
|
@ -91,6 +97,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrap: <any>true
|
||||
});
|
||||
assertWrapping(config, true, 80);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap on', () => {
|
||||
|
@ -98,6 +105,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrap: 'on'
|
||||
});
|
||||
assertWrapping(config, true, 80);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap on without minimap', () => {
|
||||
|
@ -108,6 +116,7 @@ suite('Common Editor Config', () => {
|
|||
}
|
||||
});
|
||||
assertWrapping(config, true, 88);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap on does not use wordWrapColumn', () => {
|
||||
|
@ -116,6 +125,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrapColumn: 10
|
||||
});
|
||||
assertWrapping(config, true, 80);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap off', () => {
|
||||
|
@ -123,6 +133,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrap: 'off'
|
||||
});
|
||||
assertWrapping(config, false, -1);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap off does not use wordWrapColumn', () => {
|
||||
|
@ -131,6 +142,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrapColumn: 10
|
||||
});
|
||||
assertWrapping(config, false, -1);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap wordWrapColumn uses default wordWrapColumn', () => {
|
||||
|
@ -138,6 +150,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrap: 'wordWrapColumn'
|
||||
});
|
||||
assertWrapping(config, false, 80);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap wordWrapColumn uses wordWrapColumn', () => {
|
||||
|
@ -146,6 +159,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrapColumn: 100
|
||||
});
|
||||
assertWrapping(config, false, 100);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap wordWrapColumn validates wordWrapColumn', () => {
|
||||
|
@ -154,6 +168,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrapColumn: -1
|
||||
});
|
||||
assertWrapping(config, false, 1);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap bounded uses default wordWrapColumn', () => {
|
||||
|
@ -161,6 +176,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrap: 'bounded'
|
||||
});
|
||||
assertWrapping(config, true, 80);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap bounded uses wordWrapColumn', () => {
|
||||
|
@ -169,6 +185,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrapColumn: 40
|
||||
});
|
||||
assertWrapping(config, true, 40);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('wordWrap bounded validates wordWrapColumn', () => {
|
||||
|
@ -177,6 +194,7 @@ suite('Common Editor Config', () => {
|
|||
wordWrapColumn: -1
|
||||
});
|
||||
assertWrapping(config, true, 1);
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('issue #53152: Cannot assign to read only property \'enabled\' of object', () => {
|
||||
|
@ -190,17 +208,21 @@ suite('Common Editor Config', () => {
|
|||
assert.strictEqual(config.options.get(EditorOption.hover).enabled, true);
|
||||
config.updateOptions({ hover: { enabled: false } });
|
||||
assert.strictEqual(config.options.get(EditorOption.hover).enabled, false);
|
||||
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('does not emit event when nothing changes', () => {
|
||||
const config = new TestConfiguration({ glyphMargin: true, roundedSelection: false });
|
||||
let event: ConfigurationChangedEvent | null = null;
|
||||
config.onDidChange(e => event = e);
|
||||
const disposable = config.onDidChange(e => event = e);
|
||||
assert.strictEqual(config.options.get(EditorOption.glyphMargin), true);
|
||||
|
||||
config.updateOptions({ glyphMargin: true });
|
||||
config.updateOptions({ roundedSelection: false });
|
||||
assert.strictEqual(event, null);
|
||||
config.dispose();
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('issue #94931: Unable to open source file', () => {
|
||||
|
@ -211,6 +233,7 @@ suite('Common Editor Config', () => {
|
|||
comments: 'off',
|
||||
strings: 'off'
|
||||
});
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('issue #102920: Can\'t snap or split view with JSON files', () => {
|
||||
|
@ -222,6 +245,7 @@ suite('Common Editor Config', () => {
|
|||
comments: 'off',
|
||||
strings: 'on'
|
||||
});
|
||||
config.dispose();
|
||||
});
|
||||
|
||||
test('issue #151926: Untyped editor options apply', () => {
|
||||
|
@ -239,10 +263,14 @@ suite('Common Editor Config', () => {
|
|||
allowedLocales: { "_os": true, "_vscode": true }
|
||||
}
|
||||
);
|
||||
config.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
suite('migrateOptions', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function migrate(options: any): any {
|
||||
migrateOptions(options);
|
||||
return options;
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { EditorLayoutInfo, EditorLayoutInfoComputer, RenderMinimap, EditorOption, EditorMinimapOptions, InternalEditorScrollbarOptions, EditorOptions, RenderLineNumbersType, InternalEditorRenderLineNumbersOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ComputedEditorOptions } from 'vs/editor/browser/config/editorConfiguration';
|
||||
import { EditorLayoutInfo, EditorLayoutInfoComputer, EditorMinimapOptions, EditorOption, EditorOptions, InternalEditorRenderLineNumbersOptions, InternalEditorScrollbarOptions, RenderLineNumbersType, RenderMinimap } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
interface IEditorLayoutProviderOpts {
|
||||
readonly outerWidth: number;
|
||||
|
@ -39,6 +40,8 @@ interface IEditorLayoutProviderOpts {
|
|||
|
||||
suite('Editor ViewLayout - EditorLayoutProvider', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function doTest(input: IEditorLayoutProviderOpts, expected: EditorLayoutInfo): void {
|
||||
const options = new ComputedEditorOptions();
|
||||
options._write(EditorOption.glyphMargin, input.showGlyphMargin);
|
||||
|
|
|
@ -4,30 +4,31 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { CoreEditingCommands, CoreNavigationCommands } from 'vs/editor/browser/coreCommands';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ICursorPositionChangedEvent } from 'vs/editor/common/cursorEvents';
|
||||
import { ICommand, ICursorStateComputerData, IEditOperationBuilder } from 'vs/editor/common/editorCommon';
|
||||
import { EndOfLinePreference, EndOfLineSequence, ITextModel } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { MetadataConsts, StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { EncodedTokenizationResult, IState, ITokenizationSupport, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { StandardTokenType, MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { IndentAction, IndentationRule } from 'vs/editor/common/languages/languageConfiguration';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { NullState } from 'vs/editor/common/languages/nullTokenize';
|
||||
import { withTestCodeEditor, TestCodeEditorInstantiationOptions, ITestCodeEditor, createCodeEditorServices, instantiateTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { IRelaxedTextModelCreationOptions, createTextModel, instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { javascriptOnEnterRules } from 'vs/editor/test/common/modes/supports/javascriptOnEnterRules';
|
||||
import { EndOfLinePreference, EndOfLineSequence, ITextModel } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
import { OutgoingViewModelEventKind } from 'vs/editor/common/viewModelEventDispatcher';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ICursorPositionChangedEvent } from 'vs/editor/common/cursorEvents';
|
||||
import { ITestCodeEditor, TestCodeEditorInstantiationOptions, createCodeEditorServices, instantiateTestCodeEditor, withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { javascriptOnEnterRules } from 'vs/editor/test/common/modes/supports/javascriptOnEnterRules';
|
||||
import { IRelaxedTextModelCreationOptions, createTextModel, instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
// --------- utils
|
||||
|
||||
|
@ -142,6 +143,8 @@ suite('Editor Controller - Cursor', () => {
|
|||
});
|
||||
}
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('cursor initialized', () => {
|
||||
runTest((editor, viewModel) => {
|
||||
assertCursor(viewModel, new Position(1, 1));
|
||||
|
@ -833,18 +836,20 @@ suite('Editor Controller - Cursor', () => {
|
|||
// --------- eventing
|
||||
|
||||
test('no move doesn\'t trigger event', () => {
|
||||
|
||||
runTest((editor, viewModel) => {
|
||||
viewModel.onEvent((e) => {
|
||||
const disposable = viewModel.onEvent((e) => {
|
||||
assert.ok(false, 'was not expecting event');
|
||||
});
|
||||
moveTo(editor, viewModel, 1, 1);
|
||||
disposable.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('move eventing', () => {
|
||||
runTest((editor, viewModel) => {
|
||||
let events = 0;
|
||||
viewModel.onEvent((e) => {
|
||||
const disposable = viewModel.onEvent((e) => {
|
||||
if (e.kind === OutgoingViewModelEventKind.CursorStateChanged) {
|
||||
events++;
|
||||
assert.deepStrictEqual(e.selections, [new Selection(1, 2, 1, 2)]);
|
||||
|
@ -852,13 +857,14 @@ suite('Editor Controller - Cursor', () => {
|
|||
});
|
||||
moveTo(editor, viewModel, 1, 2);
|
||||
assert.strictEqual(events, 1, 'receives 1 event');
|
||||
disposable.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('move in selection mode eventing', () => {
|
||||
runTest((editor, viewModel) => {
|
||||
let events = 0;
|
||||
viewModel.onEvent((e) => {
|
||||
const disposable = viewModel.onEvent((e) => {
|
||||
if (e.kind === OutgoingViewModelEventKind.CursorStateChanged) {
|
||||
events++;
|
||||
assert.deepStrictEqual(e.selections, [new Selection(1, 1, 1, 2)]);
|
||||
|
@ -866,6 +872,7 @@ suite('Editor Controller - Cursor', () => {
|
|||
});
|
||||
moveTo(editor, viewModel, 1, 2, true);
|
||||
assert.strictEqual(events, 1, 'receives 1 event');
|
||||
disposable.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1337,7 +1344,7 @@ suite('Editor Controller - Cursor', () => {
|
|||
|
||||
withTestCodeEditor(model, {}, (editor1, cursor1) => {
|
||||
let event: ICursorPositionChangedEvent | undefined = undefined;
|
||||
editor1.onDidChangeCursorPosition(e => {
|
||||
const disposable = editor1.onDidChangeCursorPosition(e => {
|
||||
event = e;
|
||||
});
|
||||
|
||||
|
@ -1347,6 +1354,7 @@ suite('Editor Controller - Cursor', () => {
|
|||
event = undefined;
|
||||
editor1.setPosition(new Position(1, 2), 'navigation');
|
||||
assert.strictEqual(event!.source, 'navigation');
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
languageRegistration.dispose();
|
||||
|
@ -1403,6 +1411,8 @@ suite('Editor Controller', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function setupOnEnterLanguage(indentAction: IndentAction): string {
|
||||
const onEnterLanguageId = 'onEnterMode';
|
||||
|
||||
|
@ -2210,7 +2220,7 @@ suite('Editor Controller', () => {
|
|||
moveTo(editor, viewModel, 3, 4, true);
|
||||
|
||||
let isFirst = true;
|
||||
model.onDidChangeContent(() => {
|
||||
const disposable = model.onDidChangeContent(() => {
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
viewModel.type('\t', 'keyboard');
|
||||
|
@ -2242,6 +2252,8 @@ suite('Editor Controller', () => {
|
|||
'and more lines',
|
||||
'just some text',
|
||||
].join('\n'), '004');
|
||||
|
||||
disposable.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -2726,11 +2738,13 @@ suite('Editor Controller', () => {
|
|||
withTestCodeEditor(model, {}, (editor1, cursor1) => {
|
||||
withTestCodeEditor(model, {}, (editor2, cursor2) => {
|
||||
|
||||
editor1.onDidChangeCursorPosition(() => {
|
||||
const disposable = editor1.onDidChangeCursorPosition(() => {
|
||||
model.tokenization.tokenizeIfCheap(1);
|
||||
});
|
||||
|
||||
model.applyEdits([{ range: new Range(1, 1, 1, 1), text: '-' }]);
|
||||
|
||||
disposable.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -4862,12 +4876,13 @@ suite('Editor Controller', () => {
|
|||
}, (editor, model, viewModel) => {
|
||||
moveTo(editor, viewModel, 1, 5);
|
||||
let changeText: string | null = null;
|
||||
model.onDidChangeContent(e => {
|
||||
const disposable = model.onDidChangeContent(e => {
|
||||
changeText = e.changes[0].text;
|
||||
});
|
||||
viewModel.type(')', 'keyboard');
|
||||
assert.deepStrictEqual(model.getLineContent(1), '(div)');
|
||||
assert.deepStrictEqual(changeText, ')');
|
||||
disposable.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -6170,6 +6185,8 @@ suite('Editor Controller', () => {
|
|||
|
||||
suite('Undo stops', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('there is an undo stop between typing and deleting left', () => {
|
||||
const model = createTextModel(
|
||||
[
|
||||
|
|
|
@ -4,16 +4,19 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { CoreNavigationCommands } from 'vs/editor/browser/coreCommands';
|
||||
import { CursorMove } from 'vs/editor/common/cursor/cursorMoveCommands';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { withTestCodeEditor, ITestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { CursorMove } from 'vs/editor/common/cursor/cursorMoveCommands';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
import { ITestCodeEditor, withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
|
||||
suite('Cursor move command test', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const TEXT = [
|
||||
' \tMy First Line\t ',
|
||||
'\tMy Second Line',
|
||||
|
@ -418,6 +421,8 @@ suite('Cursor move command test', () => {
|
|||
|
||||
suite('Cursor move by blankline test', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const TEXT = [
|
||||
' \tMy First Line\t ',
|
||||
'\tMy Second Line',
|
||||
|
|
|
@ -7,6 +7,7 @@ import * as assert from 'assert';
|
|||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { OperatingSystem } from 'vs/base/common/platform';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ClipboardDataToCopy, IBrowser, ICompleteTextAreaWrapper, ITextAreaInputHost, TextAreaInput } from 'vs/editor/browser/controller/textAreaInput';
|
||||
import { TextAreaState } from 'vs/editor/browser/controller/textAreaState';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
|
@ -14,6 +15,8 @@ import { IRecorded, IRecordedEvent, IRecordedTextareaState } from 'vs/editor/tes
|
|||
|
||||
suite('TextAreaInput', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
interface OutgoingType {
|
||||
type: 'type';
|
||||
text: string;
|
||||
|
@ -229,6 +232,8 @@ suite('TextAreaInput', () => {
|
|||
await yieldNow();
|
||||
}
|
||||
|
||||
disposables.dispose();
|
||||
|
||||
return outgoingEvents;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ITextAreaWrapper, PagedScreenReaderStrategy, TextAreaState } from 'vs/editor/browser/controller/textAreaState';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
|
@ -71,6 +72,8 @@ function equalsTextAreaState(a: TextAreaState, b: TextAreaState): boolean {
|
|||
|
||||
suite('TextAreaState', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function assertTextAreaState(actual: TextAreaState, value: string, selectionStart: number, selectionEnd: number): void {
|
||||
const desired = new TextAreaState(value, selectionStart, selectionEnd, null, undefined);
|
||||
assert.ok(equalsTextAreaState(desired, actual), desired.toString() + ' == ' + actual.toString());
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { RGBA8 } from 'vs/editor/common/core/rgba';
|
||||
import { Constants } from 'vs/editor/browser/viewParts/minimap/minimapCharSheet';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { MinimapCharRendererFactory } from 'vs/editor/browser/viewParts/minimap/minimapCharRendererFactory';
|
||||
import { Constants } from 'vs/editor/browser/viewParts/minimap/minimapCharSheet';
|
||||
import { RGBA8 } from 'vs/editor/common/core/rgba';
|
||||
|
||||
suite('MinimapCharRenderer', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const sampleD = [
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ILine, RenderedLinesCollection } from 'vs/editor/browser/view/viewLayer';
|
||||
|
||||
class TestLine implements ILine {
|
||||
|
@ -41,6 +42,8 @@ function assertState(col: RenderedLinesCollection<TestLine>, state: ILinesCollec
|
|||
|
||||
suite('RenderedLinesCollection onLinesDeleted', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function testOnModelLinesDeleted(deleteFromLineNumber: number, deleteToLineNumber: number, expectedDeleted: string[], expectedState: ILinesCollectionState): void {
|
||||
const col = new RenderedLinesCollection<TestLine>(() => new TestLine('new'));
|
||||
col._set(6, [
|
||||
|
@ -316,6 +319,8 @@ suite('RenderedLinesCollection onLinesDeleted', () => {
|
|||
|
||||
suite('RenderedLinesCollection onLineChanged', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function testOnModelLineChanged(changedLineNumber: number, expectedPinged: boolean, expectedState: ILinesCollectionState): void {
|
||||
const col = new RenderedLinesCollection<TestLine>(() => new TestLine('new'));
|
||||
col._set(6, [
|
||||
|
@ -397,6 +402,8 @@ suite('RenderedLinesCollection onLineChanged', () => {
|
|||
|
||||
suite('RenderedLinesCollection onLinesInserted', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function testOnModelLinesInserted(insertFromLineNumber: number, insertToLineNumber: number, expectedDeleted: string[], expectedState: ILinesCollectionState): void {
|
||||
const col = new RenderedLinesCollection<TestLine>(() => new TestLine('new'));
|
||||
col._set(6, [
|
||||
|
@ -673,6 +680,8 @@ suite('RenderedLinesCollection onLinesInserted', () => {
|
|||
|
||||
suite('RenderedLinesCollection onTokensChanged', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function testOnModelTokensChanged(changedFromLineNumber: number, changedToLineNumber: number, expectedPinged: boolean, expectedState: ILinesCollectionState): void {
|
||||
const col = new RenderedLinesCollection<TestLine>(() => new TestLine('new'));
|
||||
col._set(6, [
|
||||
|
|
|
@ -5,24 +5,28 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IViewLineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { EndOfLinePreference } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import * as languages from 'vs/editor/common/languages';
|
||||
import { NullState } from 'vs/editor/common/languages/nullTokenize';
|
||||
import { EndOfLinePreference } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ModelLineProjectionData } from 'vs/editor/common/modelLineProjectionData';
|
||||
import { IViewLineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { ViewLineData } from 'vs/editor/common/viewModel';
|
||||
import { IModelLineProjection, ISimpleModel, createModelLineProjection } from 'vs/editor/common/viewModel/modelLineProjection';
|
||||
import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/monospaceLineBreaksComputer';
|
||||
import { ViewModelLinesFromProjectedModel } from 'vs/editor/common/viewModel/viewModelLines';
|
||||
import { ViewLineData } from 'vs/editor/common/viewModel';
|
||||
import { TestConfiguration } from 'vs/editor/test/browser/config/testConfiguration';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { ISimpleModel, IModelLineProjection, createModelLineProjection } from 'vs/editor/common/viewModel/modelLineProjection';
|
||||
import { ModelLineProjectionData } from 'vs/editor/common/modelLineProjectionData';
|
||||
import { MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
|
||||
suite('Editor ViewModel - SplitLinesCollection', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('SplitLine', () => {
|
||||
let model1 = createModel('My First LineMy Second LineAnd another one');
|
||||
let line1 = createSplitLine([13, 14, 15], [13, 13 + 14, 13 + 14 + 15], 0);
|
||||
|
@ -362,6 +366,7 @@ suite('SplitLinesCollection', () => {
|
|||
languageRegistration.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
interface ITestViewLineToken {
|
||||
endIndex: number;
|
||||
|
|
|
@ -18,7 +18,8 @@ export function testViewModel(text: string[], options: IEditorOptions, callback:
|
|||
const configuration = new TestConfiguration(options);
|
||||
const model = createTextModel(text.join('\n'));
|
||||
const monospaceLineBreaksComputerFactory = MonospaceLineBreaksComputerFactory.create(configuration.options);
|
||||
const viewModel = new ViewModel(EDITOR_ID, configuration, model, monospaceLineBreaksComputerFactory, monospaceLineBreaksComputerFactory, null!, new TestLanguageConfigurationService(), new TestThemeService(), {
|
||||
const testLanguageConfigurationService = new TestLanguageConfigurationService();
|
||||
const viewModel = new ViewModel(EDITOR_ID, configuration, model, monospaceLineBreaksComputerFactory, monospaceLineBreaksComputerFactory, null!, testLanguageConfigurationService, new TestThemeService(), {
|
||||
setVisibleLines(visibleLines, stabilized) {
|
||||
},
|
||||
});
|
||||
|
@ -28,4 +29,5 @@ export function testViewModel(text: string[], options: IEditorOptions, callback:
|
|||
viewModel.dispose();
|
||||
model.dispose();
|
||||
configuration.dispose();
|
||||
testLanguageConfigurationService.dispose();
|
||||
}
|
||||
|
|
|
@ -4,12 +4,16 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { InlineDecoration, InlineDecorationType } from 'vs/editor/common/viewModel';
|
||||
import { testViewModel } from 'vs/editor/test/browser/viewModel/testViewModel';
|
||||
|
||||
suite('ViewModelDecorations', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('getDecorationsViewportData', () => {
|
||||
const text = [
|
||||
'hello world, this is a buffer that will be wrapped'
|
||||
|
|
|
@ -4,15 +4,18 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { EndOfLineSequence, PositionAffinity } from 'vs/editor/common/model';
|
||||
import { testViewModel } from 'vs/editor/test/browser/viewModel/testViewModel';
|
||||
import { ViewEventHandler } from 'vs/editor/common/viewEventHandler';
|
||||
import { ViewEvent } from 'vs/editor/common/viewEvents';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { testViewModel } from 'vs/editor/test/browser/viewModel/testViewModel';
|
||||
|
||||
suite('ViewModel', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #21073: SplitLinesCollection: attempt to access a \'newer\' model', () => {
|
||||
const text = [''];
|
||||
const opts = {
|
||||
|
@ -66,16 +69,20 @@ suite('ViewModel', () => {
|
|||
const viewLineCount: number[] = [];
|
||||
|
||||
viewLineCount.push(viewModel.getLineCount());
|
||||
viewModel.addViewEventHandler(new class extends ViewEventHandler {
|
||||
const eventHandler = new class extends ViewEventHandler {
|
||||
override handleEvents(events: ViewEvent[]): void {
|
||||
// Access the view model
|
||||
viewLineCount.push(viewModel.getLineCount());
|
||||
}
|
||||
});
|
||||
};
|
||||
viewModel.addViewEventHandler(eventHandler);
|
||||
model.undo();
|
||||
viewLineCount.push(viewModel.getLineCount());
|
||||
|
||||
assert.deepStrictEqual(viewLineCount, [4, 1, 1, 1, 1]);
|
||||
|
||||
viewModel.removeViewEventHandler(eventHandler);
|
||||
eventHandler.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -5,14 +5,17 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
|
||||
suite('CodeEditorWidget', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('onDidChangeModelDecorations', () => {
|
||||
withTestCodeEditor('', {}, (editor, viewModel) => {
|
||||
const disposables = new DisposableStore();
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { UnchangedRegion } from 'vs/editor/browser/widget/diffEditor/diffEditorViewModel';
|
||||
import { LineRange } from 'vs/editor/common/core/lineRange';
|
||||
import { DetailedLineRangeMapping } from 'vs/editor/common/diff/rangeMapping';
|
||||
|
||||
suite('DiffEditorWidget2', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
suite('UnchangedRegion', () => {
|
||||
function serialize(regions: UnchangedRegion[]): unknown {
|
||||
return regions.map(r => `${r.originalUnchangedRange} - ${r.modifiedUnchangedRange}`);
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { AtomicTabMoveOperations, Direction } from 'vs/editor/common/cursor/cursorAtomicMoveOperations';
|
||||
|
||||
suite('Cursor move command test', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Test whitespaceVisibleColumn', () => {
|
||||
const testCases = [
|
||||
{
|
||||
|
|
|
@ -3,10 +3,13 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { CursorColumns } from 'vs/editor/common/core/cursorColumns';
|
||||
|
||||
suite('CursorMove', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('nextRenderTabStop', () => {
|
||||
assert.strictEqual(CursorColumns.nextRenderTabStop(0, 4), 4);
|
||||
assert.strictEqual(CursorColumns.nextRenderTabStop(1, 4), 4);
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { CharacterClassifier } from 'vs/editor/common/core/characterClassifier';
|
||||
|
||||
suite('CharacterClassifier', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('works', () => {
|
||||
const classifier = new CharacterClassifier<number>(0);
|
||||
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { LineRange, LineRangeSet } from 'vs/editor/common/core/lineRange';
|
||||
|
||||
suite('LineRange', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('contains', () => {
|
||||
const r = new LineRange(2, 3);
|
||||
assert.deepStrictEqual(r.contains(1), false);
|
||||
|
@ -17,6 +21,9 @@ suite('LineRange', () => {
|
|||
});
|
||||
|
||||
suite('LineRangeSet', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('addRange', () => {
|
||||
const set = new LineRangeSet();
|
||||
set.addRange(new LineRange(2, 3));
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { IViewLineTokens, LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { LanguageIdCodec } from 'vs/editor/common/services/languagesRegistry';
|
||||
import { IViewLineTokens, LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
|
||||
suite('LineTokens', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
interface ILineToken {
|
||||
startIndex: number;
|
||||
foreground: number;
|
||||
|
|
|
@ -3,10 +3,14 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
|
||||
suite('Editor Core - Range', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('empty range', () => {
|
||||
const s = new Range(1, 1, 1, 1);
|
||||
assert.strictEqual(s.startLineNumber, 1);
|
||||
|
|
|
@ -6,10 +6,13 @@
|
|||
import * as assert from 'assert';
|
||||
import { writeUInt16LE } from 'vs/base/common/buffer';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { decodeUTF16LE, StringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
|
||||
suite('decodeUTF16LE', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #118041: unicode character undo bug 1', () => {
|
||||
const buff = new Uint8Array(2);
|
||||
writeUInt16LE(buff, ''.charCodeAt(0), 0);
|
||||
|
@ -37,6 +40,9 @@ suite('decodeUTF16LE', () => {
|
|||
});
|
||||
|
||||
suite('StringBuilder', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('basic', () => {
|
||||
const sb = new StringBuilder(100);
|
||||
sb.appendASCIICharCode(CharCode.A);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { Constants } from 'vs/base/common/uint';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { DiffComputer, ICharChange, ILineChange } from 'vs/editor/common/diff/legacyLinesDiffComputer';
|
||||
import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/model';
|
||||
|
@ -223,6 +224,8 @@ function createCharChange(
|
|||
|
||||
suite('Editor Diff - DiffComputer', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
// ---- insertions
|
||||
|
||||
test('one inserted line below', () => {
|
||||
|
|
|
@ -5,12 +5,16 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { splitLines } from 'vs/base/common/strings';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { BeforeEditPositionMapper, TextEditInfo } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/beforeEditPositionMapper';
|
||||
import { Length, lengthOfString, lengthToObj, lengthToPosition, toLength } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length';
|
||||
|
||||
suite('Bracket Pair Colorizer - BeforeEditPositionMapper', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Single-Line 1', () => {
|
||||
assert.deepStrictEqual(
|
||||
compute(
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { TextEditInfo } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/beforeEditPositionMapper';
|
||||
|
@ -13,6 +14,9 @@ import { TextModel } from 'vs/editor/common/model/textModel';
|
|||
import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
|
||||
suite('combineTextEditInfos', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
for (let seed = 0; seed < 50; seed++) {
|
||||
test('test' + seed, () => {
|
||||
runTest(seed);
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { AstNode, AstNodeKind, ListAstNode, TextAstNode } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/ast';
|
||||
import { toLength } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length';
|
||||
import { concat23Trees } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/concat23Trees';
|
||||
import { toLength } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length';
|
||||
|
||||
suite('Bracket Pair Colorizer - mergeItems', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Clone', () => {
|
||||
const tree = ListAstNode.create([
|
||||
new TextAstNode(toLength(1, 1)),
|
||||
|
|
|
@ -5,19 +5,22 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { DisposableStore, disposeOnReturn } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { BracketPairInfo } from 'vs/editor/common/textModelBracketPairs';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { createModelServices, instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { TokenInfo, TokenizedDocument } from 'vs/editor/test/common/model/bracketPairColorizer/tokenizer.test';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { BracketPairInfo } from 'vs/editor/common/textModelBracketPairs';
|
||||
import { TokenInfo, TokenizedDocument } from 'vs/editor/test/common/model/bracketPairColorizer/tokenizer.test';
|
||||
import { createModelServices, instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
|
||||
suite('Bracket Pair Colorizer - getBracketPairsInRange', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function createTextModelWithColorizedBracketPairs(store: DisposableStore, text: string): TextModel {
|
||||
const languageId = 'testLanguage';
|
||||
const instantiationService = createModelServices(store);
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Length, lengthAdd, lengthDiffNonNegative, lengthToObj, toLength } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length';
|
||||
|
||||
suite('Bracket Pair Colorizer - Length', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function toStr(length: Length): string {
|
||||
return lengthToObj(length).toString();
|
||||
}
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { DenseKeyProvider, SmallImmutableSet } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/smallImmutableSet';
|
||||
|
||||
suite('Bracket Pair Colorizer - ImmutableSet', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Basic', () => {
|
||||
const keyProvider = new DenseKeyProvider<string>();
|
||||
|
||||
|
|
|
@ -5,18 +5,22 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { LanguageId, MetadataConsts, StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { EncodedTokenizationResult, IState, ITokenizationSupport, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { LanguageAgnosticBracketTokens } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/brackets';
|
||||
import { Length, lengthAdd, lengthsToRange, lengthZero } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length';
|
||||
import { DenseKeyProvider } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/smallImmutableSet';
|
||||
import { TextBufferTokenizer, Token, Tokenizer, TokenKind } from 'vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/tokenizer';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { EncodedTokenizationResult, IState, ITokenizationSupport, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { LanguageId, StandardTokenType, MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { createModelServices, instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
|
||||
suite('Bracket Pair Colorizer - Tokenizer', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Basic', () => {
|
||||
const mode1 = 'testMode1';
|
||||
const disposableStore = new DisposableStore();
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { EndOfLineSequence } from 'vs/editor/common/model';
|
||||
import { SingleModelEditStackData } from 'vs/editor/common/model/editStack';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { TextChange } from 'vs/editor/common/core/textChange';
|
||||
import { EndOfLineSequence } from 'vs/editor/common/model';
|
||||
import { SingleModelEditStackData } from 'vs/editor/common/model/editStack';
|
||||
|
||||
suite('EditStack', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #118041: unicode character undo bug', () => {
|
||||
const stackData = new SingleModelEditStackData(
|
||||
1,
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { EndOfLinePreference, EndOfLineSequence } from 'vs/editor/common/model';
|
||||
|
@ -14,6 +16,8 @@ import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
|||
|
||||
suite('EditorModel - EditableTextModel.applyEdits updates mightContainRTL', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function testApplyEdits(original: string[], edits: ISingleEditOperation[], before: boolean, after: boolean): void {
|
||||
const model = createTextModel(original.join('\n'));
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
|
@ -60,6 +64,8 @@ suite('EditorModel - EditableTextModel.applyEdits updates mightContainRTL', () =
|
|||
|
||||
suite('EditorModel - EditableTextModel.applyEdits updates mightContainNonBasicASCII', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function testApplyEdits(original: string[], edits: ISingleEditOperation[], before: boolean, after: boolean): void {
|
||||
const model = createTextModel(original.join('\n'));
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
|
@ -102,6 +108,8 @@ suite('EditorModel - EditableTextModel.applyEdits updates mightContainNonBasicAS
|
|||
|
||||
suite('EditorModel - EditableTextModel.applyEdits', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text: string[]): ISingleEditOperation {
|
||||
return {
|
||||
range: new Range(startLineNumber, startColumn, endLineNumber, endColumn),
|
||||
|
@ -205,7 +213,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('Bug 19872: Undo is funky', () => {
|
||||
test('Bug 19872: Undo is funky (2)', () => {
|
||||
testApplyEditsWithSyncedModels(
|
||||
[
|
||||
'something',
|
||||
|
@ -981,7 +989,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
|||
});
|
||||
|
||||
test('change while emitting events 1', () => {
|
||||
|
||||
let disposable!: IDisposable;
|
||||
assertSyncedModels('Hello', (model, assertMirrorModels) => {
|
||||
model.applyEdits([{
|
||||
range: new Range(1, 6, 1, 6),
|
||||
|
@ -993,7 +1001,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
|||
|
||||
}, (model) => {
|
||||
let isFirstTime = true;
|
||||
model.onDidChangeContent(() => {
|
||||
disposable = model.onDidChangeContent(() => {
|
||||
if (!isFirstTime) {
|
||||
return;
|
||||
}
|
||||
|
@ -1006,10 +1014,11 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
|||
}]);
|
||||
});
|
||||
});
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('change while emitting events 2', () => {
|
||||
|
||||
let disposable!: IDisposable;
|
||||
assertSyncedModels('Hello', (model, assertMirrorModels) => {
|
||||
model.applyEdits([{
|
||||
range: new Range(1, 6, 1, 6),
|
||||
|
@ -1021,7 +1030,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
|||
|
||||
}, (model) => {
|
||||
let isFirstTime = true;
|
||||
model.onDidChangeContent((e: IModelContentChangedEvent) => {
|
||||
disposable = model.onDidChangeContent((e: IModelContentChangedEvent) => {
|
||||
if (!isFirstTime) {
|
||||
return;
|
||||
}
|
||||
|
@ -1034,6 +1043,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
|||
}]);
|
||||
});
|
||||
});
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('issue #1580: Changes in line endings are not correctly reflected in the extension host, leading to invalid offsets sent to external refactoring tools', () => {
|
||||
|
@ -1043,7 +1053,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
|||
const mirrorModel2 = new MirrorTextModel(null!, model.getLinesContent(), model.getEOL(), model.getVersionId());
|
||||
let mirrorModel2PrevVersionId = model.getVersionId();
|
||||
|
||||
model.onDidChangeContent((e: IModelContentChangedEvent) => {
|
||||
const disposable = model.onDidChangeContent((e: IModelContentChangedEvent) => {
|
||||
const versionId = e.versionId;
|
||||
if (versionId < mirrorModel2PrevVersionId) {
|
||||
console.warn('Model version id did not advance between edits (2)');
|
||||
|
@ -1060,6 +1070,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
|||
model.setEOL(EndOfLineSequence.CRLF);
|
||||
assertMirrorModels();
|
||||
|
||||
disposable.dispose();
|
||||
model.dispose();
|
||||
mirrorModel2.dispose();
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
|
@ -12,6 +13,9 @@ import { testApplyEditsWithSyncedModels } from 'vs/editor/test/common/model/edit
|
|||
const GENERATE_TESTS = false;
|
||||
|
||||
suite('EditorModel Auto Tests', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text: string[]): ISingleEditOperation {
|
||||
return {
|
||||
range: new Range(startLineNumber, startColumn, endLineNumber, endColumn),
|
||||
|
|
|
@ -100,7 +100,7 @@ export function assertSyncedModels(text: string, callback: (model: TextModel, as
|
|||
const mirrorModel2 = new MirrorTextModel(null!, model.getLinesContent(), model.getEOL(), model.getVersionId());
|
||||
let mirrorModel2PrevVersionId = model.getVersionId();
|
||||
|
||||
model.onDidChangeContent((e: IModelContentChangedEvent) => {
|
||||
const disposable = model.onDidChangeContent((e: IModelContentChangedEvent) => {
|
||||
const versionId = e.versionId;
|
||||
if (versionId < mirrorModel2PrevVersionId) {
|
||||
console.warn('Model version id did not advance between edits (2)');
|
||||
|
@ -117,6 +117,7 @@ export function assertSyncedModels(text: string, callback: (model: TextModel, as
|
|||
|
||||
callback(model, assertMirrorModels);
|
||||
|
||||
disposable.dispose();
|
||||
model.dispose();
|
||||
mirrorModel2.dispose();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { TrackedRangeStickiness } from 'vs/editor/common/model';
|
||||
import { IntervalNode, IntervalTree, NodeColor, SENTINEL, getNodeColor, intervalCompare, nodeAcceptEdit, setNodeStickiness } from 'vs/editor/common/model/intervalTree';
|
||||
|
||||
|
@ -19,6 +20,8 @@ const MAX_CHANGE_CNT = 20;
|
|||
|
||||
suite('IntervalTree 1', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
class Interval {
|
||||
_intervalBrand: void = undefined;
|
||||
|
||||
|
@ -555,6 +558,9 @@ suite('IntervalTree 1', () => {
|
|||
});
|
||||
|
||||
suite('IntervalTree 2', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function assertNodeAcceptEdit(msg: string, nodeStart: number, nodeEnd: number, nodeStickiness: TrackedRangeStickiness, start: number, end: number, textLength: number, forceMoveMarkers: boolean, expectedNodeStart: number, expectedNodeEnd: number): void {
|
||||
const node = new IntervalNode('', nodeStart, nodeEnd);
|
||||
setNodeStickiness(node, nodeStickiness);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { IValidatedEditOperation, PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
||||
|
@ -11,6 +12,8 @@ import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
|||
|
||||
suite('PieceTreeTextBuffer._getInverseEdits', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text: string[] | null): IValidatedEditOperation {
|
||||
return {
|
||||
sortIndex: 0,
|
||||
|
@ -265,6 +268,8 @@ suite('PieceTreeTextBuffer._getInverseEdits', () => {
|
|||
|
||||
suite('PieceTreeTextBuffer._toSingleEditOperation', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, rangeOffset: number, rangeLength: number, text: string[] | null): IValidatedEditOperation {
|
||||
return {
|
||||
sortIndex: 0,
|
||||
|
@ -282,10 +287,11 @@ suite('PieceTreeTextBuffer._toSingleEditOperation', () => {
|
|||
}
|
||||
|
||||
function testToSingleEditOperation(original: string[], edits: IValidatedEditOperation[], expected: IValidatedEditOperation): void {
|
||||
const textBuffer = <PieceTreeTextBuffer>createTextBufferFactory(original.join('\n')).create(DefaultEndOfLine.LF).textBuffer;
|
||||
const { disposable, textBuffer } = createTextBufferFactory(original.join('\n')).create(DefaultEndOfLine.LF);
|
||||
|
||||
const actual = textBuffer._toSingleEditOperation(edits);
|
||||
const actual = (<PieceTreeTextBuffer>textBuffer)._toSingleEditOperation(edits);
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
test('one edit op is unchanged', () => {
|
||||
|
|
|
@ -5,20 +5,23 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
|
||||
function testTextBufferFactory(text: string, eol: string, mightContainNonBasicASCII: boolean, mightContainRTL: boolean): void {
|
||||
const textBuffer = <PieceTreeTextBuffer>createTextBufferFactory(text).create(DefaultEndOfLine.LF).textBuffer;
|
||||
const { disposable, textBuffer } = createTextBufferFactory(text).create(DefaultEndOfLine.LF);
|
||||
|
||||
assert.strictEqual(textBuffer.mightContainNonBasicASCII(), mightContainNonBasicASCII);
|
||||
assert.strictEqual(textBuffer.mightContainRTL(), mightContainRTL);
|
||||
assert.strictEqual(textBuffer.getEOL(), eol);
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
suite('ModelBuilder', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('t1', () => {
|
||||
testTextBufferFactory('', '\n', false, false);
|
||||
});
|
||||
|
@ -51,10 +54,6 @@ suite('ModelBuilder', () => {
|
|||
testTextBufferFactory(strings.UTF8_BOM_CHARACTER + 'Hello world!', '\n', false, false);
|
||||
});
|
||||
|
||||
test('BOM handling', () => {
|
||||
testTextBufferFactory(strings.UTF8_BOM_CHARACTER + 'Hello world!', '\n', false, false);
|
||||
});
|
||||
|
||||
test('RTL handling 2', () => {
|
||||
testTextBufferFactory('Hello world!זוהי עובדה מבוססת שדעתו', '\n', true, true);
|
||||
});
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { computeIndentLevel } from 'vs/editor/common/model/utils';
|
||||
import { MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { EncodedTokenizationResult, IBackgroundTokenizationStore, IBackgroundTokenizer, IState, ITokenizationSupport, TokenizationRegistry, TokenizationResult } from 'vs/editor/common/languages';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { computeIndentLevel } from 'vs/editor/common/model/utils';
|
||||
import { ContiguousMultilineTokensBuilder } from 'vs/editor/common/tokens/contiguousMultilineTokensBuilder';
|
||||
import { LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { TestLineToken, TestLineTokenFactory } from 'vs/editor/test/common/core/testLineToken';
|
||||
import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { ITokenizationSupport, TokenizationRegistry, IState, IBackgroundTokenizationStore, EncodedTokenizationResult, TokenizationResult, IBackgroundTokenizer } from 'vs/editor/common/languages';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ContiguousMultilineTokensBuilder } from 'vs/editor/common/tokens/contiguousMultilineTokensBuilder';
|
||||
|
||||
interface ILineEdit {
|
||||
startColumn: number;
|
||||
|
@ -46,6 +47,9 @@ function assertLineTokens(__actual: LineTokens, _expected: TestToken[]): void {
|
|||
}
|
||||
|
||||
suite('ModelLine - getIndentLevel', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function assertIndentLevel(text: string, expected: number, tabSize: number = 4): void {
|
||||
const actual = computeIndentLevel(text, tabSize);
|
||||
assert.strictEqual(actual, expected, text);
|
||||
|
@ -148,6 +152,8 @@ class LineState implements IState {
|
|||
|
||||
suite('ModelLinesTokens', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
interface IBufferLineState {
|
||||
text: string;
|
||||
tokens: TestToken[];
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import * as languages from 'vs/editor/common/languages';
|
||||
import { NullState } from 'vs/editor/common/languages/nullTokenize';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
|
||||
// --------- utils
|
||||
|
@ -56,6 +57,8 @@ suite('Editor Model - Model Modes 1', () => {
|
|||
calledFor = [];
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('model calls syntax highlighter 1', () => {
|
||||
thisModel.tokenization.forceTokenization(1);
|
||||
assert.deepStrictEqual(getAndClear(), ['1']);
|
||||
|
@ -209,6 +212,8 @@ suite('Editor Model - Model Modes 2', () => {
|
|||
languageRegistration.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('getTokensForInvalidLines one text insert', () => {
|
||||
thisModel.tokenization.forceTokenization(5);
|
||||
assert.deepStrictEqual(getAndClear(), ['Line1', 'Line2', 'Line3', 'Line4', 'Line5']);
|
||||
|
|
|
@ -5,17 +5,18 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { Disposable, DisposableStore, dispose } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { InternalModelContentChangeEvent, ModelRawContentChangedEvent, ModelRawFlush, ModelRawLineChanged, ModelRawLinesDeleted, ModelRawLinesInserted } from 'vs/editor/common/textModelEvents';
|
||||
import { EncodedTokenizationResult, IState, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { EncodedTokenizationResult, IState, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { NullState } from 'vs/editor/common/languages/nullTokenize';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { InternalModelContentChangeEvent, ModelRawContentChangedEvent, ModelRawFlush, ModelRawLineChanged, ModelRawLinesDeleted, ModelRawLinesInserted } from 'vs/editor/common/textModelEvents';
|
||||
import { createModelServices, createTextModel, instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
|
||||
// --------- utils
|
||||
|
||||
|
@ -43,6 +44,8 @@ suite('Editor Model - Model', () => {
|
|||
thisModel.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
// --------- insert text
|
||||
|
||||
test('model getValue', () => {
|
||||
|
@ -96,15 +99,16 @@ suite('Editor Model - Model', () => {
|
|||
// --------- insert text eventing
|
||||
|
||||
test('model insert empty text does not trigger eventing', () => {
|
||||
thisModel.onDidChangeContentOrInjectedText((e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((e) => {
|
||||
assert.ok(false, 'was not expecting event');
|
||||
});
|
||||
thisModel.applyEdits([EditOperation.insert(new Position(1, 1), '')]);
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('model insert text without newline eventing', () => {
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
if (e !== null || !(_e instanceof InternalModelContentChangeEvent)) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
}
|
||||
|
@ -119,11 +123,12 @@ suite('Editor Model - Model', () => {
|
|||
false,
|
||||
false
|
||||
));
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('model insert text with one newline eventing', () => {
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
if (e !== null || !(_e instanceof InternalModelContentChangeEvent)) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
}
|
||||
|
@ -139,6 +144,7 @@ suite('Editor Model - Model', () => {
|
|||
false,
|
||||
false
|
||||
));
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
|
||||
|
@ -192,15 +198,16 @@ suite('Editor Model - Model', () => {
|
|||
// --------- delete text eventing
|
||||
|
||||
test('model delete empty text does not trigger eventing', () => {
|
||||
thisModel.onDidChangeContentOrInjectedText((e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((e) => {
|
||||
assert.ok(false, 'was not expecting event');
|
||||
});
|
||||
thisModel.applyEdits([EditOperation.delete(new Range(1, 1, 1, 1))]);
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('model delete text from one line eventing', () => {
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
if (e !== null || !(_e instanceof InternalModelContentChangeEvent)) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
}
|
||||
|
@ -215,11 +222,12 @@ suite('Editor Model - Model', () => {
|
|||
false,
|
||||
false
|
||||
));
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('model delete all text from a line eventing', () => {
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
if (e !== null || !(_e instanceof InternalModelContentChangeEvent)) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
}
|
||||
|
@ -234,11 +242,12 @@ suite('Editor Model - Model', () => {
|
|||
false,
|
||||
false
|
||||
));
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('model delete text from two lines eventing', () => {
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
if (e !== null || !(_e instanceof InternalModelContentChangeEvent)) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
}
|
||||
|
@ -254,11 +263,12 @@ suite('Editor Model - Model', () => {
|
|||
false,
|
||||
false
|
||||
));
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('model delete text from many lines eventing', () => {
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
if (e !== null || !(_e instanceof InternalModelContentChangeEvent)) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
}
|
||||
|
@ -274,6 +284,7 @@ suite('Editor Model - Model', () => {
|
|||
false,
|
||||
false
|
||||
));
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
// --------- getValueInRange
|
||||
|
@ -309,7 +320,7 @@ suite('Editor Model - Model', () => {
|
|||
// --------- setValue
|
||||
test('setValue eventing', () => {
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
const disposable = thisModel.onDidChangeContentOrInjectedText((_e) => {
|
||||
if (e !== null || !(_e instanceof InternalModelContentChangeEvent)) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
}
|
||||
|
@ -324,6 +335,7 @@ suite('Editor Model - Model', () => {
|
|||
false,
|
||||
false
|
||||
));
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('issue #46342: Maintain edit operation order in applyEdits', () => {
|
||||
|
@ -357,6 +369,8 @@ suite('Editor Model - Model Line Separators', () => {
|
|||
thisModel.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('model getValue', () => {
|
||||
assert.strictEqual(thisModel.getValue(), 'My First Line\u2028\t\tMy Second Line\n Third Line\u2028\n1');
|
||||
});
|
||||
|
@ -445,6 +459,8 @@ suite('Editor Model - Words', () => {
|
|||
disposables = [];
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Get word at position', () => {
|
||||
const text = ['This text has some words. '];
|
||||
const thisModel = createTextModel(text.join('\n'));
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
|
@ -101,6 +102,8 @@ suite('Editor Model - Model Decorations', () => {
|
|||
thisModel.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('single character decoration', () => {
|
||||
addDecoration(thisModel, 1, 1, 1, 2, 'myType');
|
||||
lineHasDecoration(thisModel, 1, 1, 2, 'myType');
|
||||
|
@ -206,53 +209,57 @@ suite('Editor Model - Model Decorations', () => {
|
|||
|
||||
test('decorations emit event on add', () => {
|
||||
let listenerCalled = 0;
|
||||
thisModel.onDidChangeDecorations((e) => {
|
||||
const disposable = thisModel.onDidChangeDecorations((e) => {
|
||||
listenerCalled++;
|
||||
});
|
||||
addDecoration(thisModel, 1, 2, 3, 2, 'myType');
|
||||
assert.strictEqual(listenerCalled, 1, 'listener called');
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('decorations emit event on change', () => {
|
||||
let listenerCalled = 0;
|
||||
const decId = addDecoration(thisModel, 1, 2, 3, 2, 'myType');
|
||||
thisModel.onDidChangeDecorations((e) => {
|
||||
const disposable = thisModel.onDidChangeDecorations((e) => {
|
||||
listenerCalled++;
|
||||
});
|
||||
thisModel.changeDecorations((changeAccessor) => {
|
||||
changeAccessor.changeDecoration(decId, new Range(1, 1, 1, 2));
|
||||
});
|
||||
assert.strictEqual(listenerCalled, 1, 'listener called');
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('decorations emit event on remove', () => {
|
||||
let listenerCalled = 0;
|
||||
const decId = addDecoration(thisModel, 1, 2, 3, 2, 'myType');
|
||||
thisModel.onDidChangeDecorations((e) => {
|
||||
const disposable = thisModel.onDidChangeDecorations((e) => {
|
||||
listenerCalled++;
|
||||
});
|
||||
thisModel.changeDecorations((changeAccessor) => {
|
||||
changeAccessor.removeDecoration(decId);
|
||||
});
|
||||
assert.strictEqual(listenerCalled, 1, 'listener called');
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('decorations emit event when inserting one line text before it', () => {
|
||||
let listenerCalled = 0;
|
||||
addDecoration(thisModel, 1, 2, 3, 2, 'myType');
|
||||
|
||||
thisModel.onDidChangeDecorations((e) => {
|
||||
const disposable = thisModel.onDidChangeDecorations((e) => {
|
||||
listenerCalled++;
|
||||
});
|
||||
|
||||
thisModel.applyEdits([EditOperation.insert(new Position(1, 1), 'Hallo ')]);
|
||||
assert.strictEqual(listenerCalled, 1, 'listener called');
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
test('decorations do not emit event on no-op deltaDecorations', () => {
|
||||
let listenerCalled = 0;
|
||||
|
||||
thisModel.onDidChangeDecorations((e) => {
|
||||
const disposable = thisModel.onDidChangeDecorations((e) => {
|
||||
listenerCalled++;
|
||||
});
|
||||
|
||||
|
@ -262,6 +269,7 @@ suite('Editor Model - Model Decorations', () => {
|
|||
});
|
||||
|
||||
assert.strictEqual(listenerCalled, 0, 'listener not called');
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
// --------- editing text & effects on decorations
|
||||
|
@ -416,6 +424,8 @@ suite('Editor Model - Model Decorations', () => {
|
|||
|
||||
suite('Decorations and editing', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function _runTest(decRange: Range, stickiness: TrackedRangeStickiness, editRange: Range, editText: string, editForceMoveMarkers: boolean, expectedDecRange: Range, msg: string): void {
|
||||
const model = createTextModel([
|
||||
'My First Line',
|
||||
|
@ -1113,6 +1123,8 @@ interface ILightWeightDecoration {
|
|||
|
||||
suite('deltaDecorations', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function decoration(id: string, startLineNumber: number, startColumn: number, endLineNumber: number, endColum: number): ILightWeightDecoration {
|
||||
return {
|
||||
id: id,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
|
@ -31,6 +32,8 @@ suite('Editor Model - Model Edit Operation', () => {
|
|||
model.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function createSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): ISingleEditOperation {
|
||||
const range = new Range(
|
||||
selectionLineNumber,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { compressConsecutiveTextChanges, TextChange } from 'vs/editor/common/core/textChange';
|
||||
|
||||
const GENERATE_TESTS = false;
|
||||
|
@ -16,6 +17,8 @@ interface IGeneratedEdit {
|
|||
|
||||
suite('TextChangeCompressor', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function getResultingContent(initialContent: string, edits: IGeneratedEdit[]): string {
|
||||
let content = initialContent;
|
||||
for (let i = edits.length - 1; i >= 0; i--) {
|
||||
|
@ -283,6 +286,8 @@ suite('TextChangeCompressor', () => {
|
|||
|
||||
suite('TextChange', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #118041: unicode character undo bug', () => {
|
||||
const textChange = new TextChange(428, '', 428, '');
|
||||
const buff = new Uint8Array(textChange.writeSize());
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import * as assert from 'assert';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { UTF8_BOM_CHARACTER } from 'vs/base/common/strings';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry';
|
||||
|
@ -72,6 +73,8 @@ function assertGuess(expectedInsertSpaces: boolean | undefined, expectedTabSize:
|
|||
|
||||
suite('TextModelData.fromString', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
interface ITextBufferData {
|
||||
EOL: string;
|
||||
lines: string[];
|
||||
|
@ -80,7 +83,7 @@ suite('TextModelData.fromString', () => {
|
|||
}
|
||||
|
||||
function testTextModelDataFromString(text: string, expected: ITextBufferData): void {
|
||||
const textBuffer = createTextBuffer(text, TextModel.DEFAULT_CREATION_OPTIONS.defaultEOL).textBuffer;
|
||||
const { textBuffer, disposable } = createTextBuffer(text, TextModel.DEFAULT_CREATION_OPTIONS.defaultEOL);
|
||||
const actual: ITextBufferData = {
|
||||
EOL: textBuffer.getEOL(),
|
||||
lines: textBuffer.getLinesContent(),
|
||||
|
@ -88,6 +91,7 @@ suite('TextModelData.fromString', () => {
|
|||
isBasicASCII: !textBuffer.mightContainNonBasicASCII()
|
||||
};
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
test('one line text', () => {
|
||||
|
@ -166,6 +170,8 @@ suite('TextModelData.fromString', () => {
|
|||
|
||||
suite('Editor Model - TextModel', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('TextModel does not use events internally', () => {
|
||||
// Make sure that all model parts receive text model events explicitly
|
||||
// to avoid that by any chance an outside listener receives events before
|
||||
|
@ -1067,6 +1073,8 @@ suite('Editor Model - TextModel', () => {
|
|||
|
||||
suite('TextModel.mightContainRTL', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('nope', () => {
|
||||
const model = createTextModel('hello world!');
|
||||
assert.strictEqual(model.mightContainRTL(), false);
|
||||
|
@ -1099,6 +1107,8 @@ suite('TextModel.mightContainRTL', () => {
|
|||
|
||||
suite('TextModel.createSnapshot', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('empty file', () => {
|
||||
const model = createTextModel('');
|
||||
const snapshot = model.createSnapshot();
|
||||
|
|
|
@ -4,18 +4,21 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { getMapForWordSeparators } from 'vs/editor/common/core/wordCharacterClassifier';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { getMapForWordSeparators } from 'vs/editor/common/core/wordCharacterClassifier';
|
||||
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/core/wordHelper';
|
||||
import { EndOfLineSequence, FindMatch, SearchData } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { SearchParams, TextModelSearch, isMultilineRegexSource } from 'vs/editor/common/model/textModelSearch';
|
||||
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/core/wordHelper';
|
||||
import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
|
||||
// --------- Find
|
||||
suite('TextModelSearch', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const usualWordSeparators = getMapForWordSeparators(USUAL_WORD_SEPARATORS);
|
||||
|
||||
function assertFindMatch(actual: FindMatch | null, expectedRange: Range, expectedMatches: string[] | null = null): void {
|
||||
|
|
|
@ -4,11 +4,14 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
|
||||
import { RangePriorityQueueImpl } from 'vs/editor/common/model/textModelTokens';
|
||||
|
||||
suite('RangePriorityQueueImpl', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('addRange', () => {
|
||||
const ranges: OffsetRange[] = [];
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import { ILanguageService } from 'vs/editor/common/languages/language';
|
|||
import { TestLineToken } from 'vs/editor/test/common/core/testLineToken';
|
||||
import { createModelServices, createTextModel, instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
|
||||
function createTextModelWithBrackets(disposables: DisposableStore, text: string, brackets: CharacterPair[]): TextModel {
|
||||
const languageId = 'bracketMode2';
|
||||
|
@ -32,6 +33,9 @@ function createTextModelWithBrackets(disposables: DisposableStore, text: string,
|
|||
}
|
||||
|
||||
suite('TextModelWithTokens', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function testBrackets(contents: string[], brackets: CharacterPair[]): void {
|
||||
const languageId = 'testMode';
|
||||
const disposables = new DisposableStore();
|
||||
|
@ -194,6 +198,8 @@ suite('TextModelWithTokens - bracket matching', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('bracket matching 1', () => {
|
||||
const text =
|
||||
')]}{[(' + '\n' +
|
||||
|
@ -273,6 +279,8 @@ suite('TextModelWithTokens - bracket matching', () => {
|
|||
|
||||
suite('TextModelWithTokens 2', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('bracket matching 3', () => {
|
||||
const text = [
|
||||
'begin',
|
||||
|
@ -534,6 +542,8 @@ suite('TextModelWithTokens 2', () => {
|
|||
|
||||
suite('TextModelWithTokens regression tests', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('microsoft/monaco-editor#122: Unhandled Exception: TypeError: Unable to get property \'replace\' of undefined or null reference', () => {
|
||||
function assertViewLineTokens(model: TextModel, lineNumber: number, forceTokenization: boolean, expected: TestLineToken[]): void {
|
||||
if (forceTokenization) {
|
||||
|
@ -699,6 +709,9 @@ suite('TextModelWithTokens regression tests', () => {
|
|||
});
|
||||
|
||||
suite('TextModel.getLineIndentGuide', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function assertIndentGuides(lines: [number, number, number, number, string][], indentSize: number): void {
|
||||
const languageId = 'testLang';
|
||||
const disposables = new DisposableStore();
|
||||
|
|
|
@ -4,21 +4,24 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ColorId, FontStyle, MetadataConsts, TokenMetadata } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { ILanguageConfigurationService, LanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { LanguageIdCodec } from 'vs/editor/common/services/languagesRegistry';
|
||||
import { LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { SparseMultilineTokens } from 'vs/editor/common/tokens/sparseMultilineTokens';
|
||||
import { SparseTokensStore } from 'vs/editor/common/tokens/sparseTokensStore';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { FontStyle, ColorId, MetadataConsts, TokenMetadata } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { createModelServices, createTextModel, instantiateTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
import { LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { LanguageIdCodec } from 'vs/editor/common/services/languagesRegistry';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ILanguageConfigurationService, LanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
|
||||
suite('TokensStore', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const SEMANTIC_COLOR = 5 as ColorId;
|
||||
|
||||
function parseTokensState(state: string[]): { text: string; tokens: SparseMultilineTokens } {
|
||||
|
@ -253,7 +256,7 @@ suite('TokensStore', () => {
|
|||
const instantiationService = createModelServices(disposables, [
|
||||
[ILanguageConfigurationService, LanguageConfigurationService]
|
||||
]);
|
||||
const model = instantiateTextModel(instantiationService, '--[[\n\n]]');
|
||||
const model = disposables.add(instantiateTextModel(instantiationService, '--[[\n\n]]'));
|
||||
model.tokenization.setSemanticTokens([
|
||||
SparseMultilineTokens.create(1, new Uint32Array([
|
||||
0, 2, 4, 0b100000000000010000,
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { StandardAutoClosingPairConditional } from 'vs/editor/common/languages/languageConfiguration';
|
||||
import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService';
|
||||
|
||||
suite('StandardAutoClosingPairConditional', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Missing notIn', () => {
|
||||
const v = new StandardAutoClosingPairConditional({ open: '{', close: '}' });
|
||||
assert.strictEqual(v.isOK(StandardTokenType.Other), true);
|
||||
|
@ -98,5 +101,6 @@ suite('StandardAutoClosingPairConditional', () => {
|
|||
assert.strictEqual(languageConfigurationService.getLanguageConfiguration(id).comments?.lineCommentToken, '1');
|
||||
d1.dispose();
|
||||
d2.dispose();
|
||||
languageConfigurationService.dispose();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { LanguageSelector, score } from 'vs/editor/common/languageSelector';
|
||||
|
||||
suite('LanguageSelector', function () {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
const model = {
|
||||
language: 'farboo',
|
||||
uri: URI.parse('file:///testbed/file.fb')
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ILink } from 'vs/editor/common/languages';
|
||||
import { ILinkComputerTarget, computeLinks } from 'vs/editor/common/languages/linkComputer';
|
||||
|
||||
|
@ -62,6 +63,8 @@ function assertLink(text: string, extractedLink: string): void {
|
|||
|
||||
suite('Editor Modes - Link Computer', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Null model', () => {
|
||||
const r = computeLinks(null);
|
||||
assert.deepStrictEqual(r, []);
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { StandardAutoClosingPairConditional } from 'vs/editor/common/languages/languageConfiguration';
|
||||
import { CharacterPairSupport } from 'vs/editor/common/languages/supports/characterPair';
|
||||
import { TokenText, createFakeScopedLineTokens } from 'vs/editor/test/common/modesTestUtils';
|
||||
import { StandardAutoClosingPairConditional } from 'vs/editor/common/languages/languageConfiguration';
|
||||
|
||||
suite('CharacterPairSupport', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('only autoClosingPairs', () => {
|
||||
const characaterPairSupport = new CharacterPairSupport({ autoClosingPairs: [{ open: 'a', close: 'b' }] });
|
||||
assert.deepStrictEqual(characaterPairSupport.getAutoClosingPairs(), [new StandardAutoClosingPairConditional({ open: 'a', close: 'b' })]);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { StandardTokenType } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { BracketElectricCharacterSupport, IElectricAction } from 'vs/editor/common/languages/supports/electricCharacter';
|
||||
import { RichEditBrackets } from 'vs/editor/common/languages/supports/richEditBrackets';
|
||||
|
@ -12,6 +13,9 @@ import { TokenText, createFakeScopedLineTokens } from 'vs/editor/test/common/mod
|
|||
const fakeLanguageId = 'test';
|
||||
|
||||
suite('Editor Modes - Auto Indentation', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function _testOnElectricCharacter(electricCharacterSupport: BracketElectricCharacterSupport, line: TokenText[], character: string, offset: number): IElectricAction | null {
|
||||
return electricCharacterSupport.onElectricCharacter(character, createFakeScopedLineTokens(line), offset);
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@ import { CharacterPair, IndentAction } from 'vs/editor/common/languages/language
|
|||
import { OnEnterSupport } from 'vs/editor/common/languages/supports/onEnter';
|
||||
import { javascriptOnEnterRules } from 'vs/editor/test/common/modes/supports/javascriptOnEnterRules';
|
||||
import { EditorAutoIndentStrategy } from 'vs/editor/common/config/editorOptions';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
|
||||
suite('OnEnter', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('uses brackets', () => {
|
||||
const brackets: CharacterPair[] = [
|
||||
['(', ')'],
|
||||
|
|
|
@ -4,11 +4,14 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { BracketsUtils } from 'vs/editor/common/languages/supports/richEditBrackets';
|
||||
|
||||
suite('richEditBrackets', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function findPrevBracketInRange(reversedBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range | null {
|
||||
return BracketsUtils.findPrevBracketInRange(reversedBracketRegex, 1, lineText, currentTokenStart, currentTokenEnd);
|
||||
}
|
||||
|
|
|
@ -4,11 +4,14 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { FontStyle } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { ColorMap, ExternalThemeTrieElement, ParsedTokenThemeRule, ThemeTrieElementRule, TokenTheme, parseTokenTheme, strcmp } from 'vs/editor/common/languages/supports/tokenization';
|
||||
|
||||
suite('Token theme matching', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('gives higher priority to deeper matches', () => {
|
||||
const theme = TokenTheme.createFromRawTokenTheme([
|
||||
{ token: '', foreground: '100000', background: '200000' },
|
||||
|
@ -127,6 +130,8 @@ suite('Token theme matching', () => {
|
|||
|
||||
suite('Token theme parsing', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('can parse', () => {
|
||||
|
||||
const actual = parseTokenTheme([
|
||||
|
@ -163,6 +168,8 @@ suite('Token theme parsing', () => {
|
|||
|
||||
suite('Token theme resolving', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('strcmp works', () => {
|
||||
const actual = ['bar', 'z', 'zu', 'a', 'ab', ''].sort(strcmp);
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ColorId, FontStyle, MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { EncodedTokenizationResult, IState, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { FontStyle, ColorId, MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { tokenizeLineToHTML, _tokenizeToString } from 'vs/editor/common/languages/textToHtmlTokenizer';
|
||||
import { _tokenizeToString, tokenizeLineToHTML } from 'vs/editor/common/languages/textToHtmlTokenizer';
|
||||
import { LanguageIdCodec } from 'vs/editor/common/services/languagesRegistry';
|
||||
import { TestLineToken, TestLineTokens } from 'vs/editor/test/common/core/testLineToken';
|
||||
import { createModelServices } from 'vs/editor/test/common/testTextModel';
|
||||
|
@ -28,6 +29,8 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function toStr(pieces: { className: string; text: string }[]): string {
|
||||
const resultArr = pieces.map((t) => `<span class="${t.className}">${t.text}</span>`);
|
||||
return resultArr.join('');
|
||||
|
|
|
@ -4,14 +4,17 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { TextEdit } from 'vs/editor/common/languages';
|
||||
import { EditorSimpleWorker, ICommonModel } from 'vs/editor/common/services/editorSimpleWorker';
|
||||
import { IEditorWorkerHost } from 'vs/editor/common/services/editorWorkerHost';
|
||||
|
||||
suite('EditorSimpleWorker', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
class WorkerWithModels extends EditorSimpleWorker {
|
||||
|
||||
getModel(uri: string) {
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { getMimeTypes, registerPlatformLanguageAssociation, registerConfiguredLanguageAssociation } from 'vs/editor/common/services/languagesAssociations';
|
||||
|
||||
suite('LanguagesAssociations', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Dynamically Register Text Mime', () => {
|
||||
let guess = getMimeTypes(URI.file('foo.monaco'));
|
||||
assert.deepStrictEqual(guess, ['application/unknown']);
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { LanguagesRegistry } from 'vs/editor/common/services/languagesRegistry';
|
||||
|
||||
suite('LanguagesRegistry', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('output language does not have a name', () => {
|
||||
const registry = new LanguagesRegistry(false);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
|
|||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { StringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { DefaultEndOfLine, ITextBuffer, ITextBufferFactory, ITextSnapshot } from 'vs/editor/common/model';
|
||||
import { createTextBuffer } from 'vs/editor/common/model/textModel';
|
||||
import { ModelService } from 'vs/editor/common/services/modelService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
|
@ -20,6 +20,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
|
|||
import { IModelService } from 'vs/editor/common/services/model';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
|
||||
const GENERATE_TESTS = false;
|
||||
|
||||
|
@ -45,6 +46,8 @@ suite('ModelService', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('EOL setting respected depending on root', () => {
|
||||
const model1 = modelService.createModel('farboo', null);
|
||||
const model2 = modelService.createModel('farboo', null, URI.file(platform.isWindows ? 'c:\\myroot\\myfile.txt' : '/myroot/myfile.txt'));
|
||||
|
@ -53,6 +56,10 @@ suite('ModelService', () => {
|
|||
assert.strictEqual(model1.getOptions().defaultEOL, DefaultEndOfLine.LF);
|
||||
assert.strictEqual(model2.getOptions().defaultEOL, DefaultEndOfLine.CRLF);
|
||||
assert.strictEqual(model3.getOptions().defaultEOL, DefaultEndOfLine.LF);
|
||||
|
||||
model1.dispose();
|
||||
model2.dispose();
|
||||
model3.dispose();
|
||||
});
|
||||
|
||||
test('_computeEdits no change', function () {
|
||||
|
@ -66,7 +73,8 @@ suite('ModelService', () => {
|
|||
].join('\n')
|
||||
));
|
||||
|
||||
const textBuffer = createTextBuffer(
|
||||
const textBuffer = createAndRegisterTextBuffer(
|
||||
disposables,
|
||||
[
|
||||
'This is line one', //16
|
||||
'and this is line number two', //27
|
||||
|
@ -74,7 +82,7 @@ suite('ModelService', () => {
|
|||
'and finished with the fourth.', //29
|
||||
].join('\n'),
|
||||
DefaultEndOfLine.LF
|
||||
).textBuffer;
|
||||
);
|
||||
|
||||
const actual = ModelService._computeEdits(model, textBuffer);
|
||||
|
||||
|
@ -92,7 +100,8 @@ suite('ModelService', () => {
|
|||
].join('\n')
|
||||
));
|
||||
|
||||
const textBuffer = createTextBuffer(
|
||||
const textBuffer = createAndRegisterTextBuffer(
|
||||
disposables,
|
||||
[
|
||||
'This is line One', //16
|
||||
'and this is line number two', //27
|
||||
|
@ -100,7 +109,7 @@ suite('ModelService', () => {
|
|||
'and finished with the fourth.', //29
|
||||
].join('\n'),
|
||||
DefaultEndOfLine.LF
|
||||
).textBuffer;
|
||||
);
|
||||
|
||||
const actual = ModelService._computeEdits(model, textBuffer);
|
||||
|
||||
|
@ -120,7 +129,8 @@ suite('ModelService', () => {
|
|||
].join('\n')
|
||||
));
|
||||
|
||||
const textBuffer = createTextBuffer(
|
||||
const textBuffer = createAndRegisterTextBuffer(
|
||||
disposables,
|
||||
[
|
||||
'This is line one', //16
|
||||
'and this is line number two', //27
|
||||
|
@ -128,7 +138,7 @@ suite('ModelService', () => {
|
|||
'and finished with the fourth.', //29
|
||||
].join('\r\n'),
|
||||
DefaultEndOfLine.LF
|
||||
).textBuffer;
|
||||
);
|
||||
|
||||
const actual = ModelService._computeEdits(model, textBuffer);
|
||||
|
||||
|
@ -146,7 +156,8 @@ suite('ModelService', () => {
|
|||
].join('\n')
|
||||
));
|
||||
|
||||
const textBuffer = createTextBuffer(
|
||||
const textBuffer = createAndRegisterTextBuffer(
|
||||
disposables,
|
||||
[
|
||||
'This is line One', //16
|
||||
'and this is line number two', //27
|
||||
|
@ -154,7 +165,7 @@ suite('ModelService', () => {
|
|||
'and finished with the fourth.', //29
|
||||
].join('\r\n'),
|
||||
DefaultEndOfLine.LF
|
||||
).textBuffer;
|
||||
);
|
||||
|
||||
const actual = ModelService._computeEdits(model, textBuffer);
|
||||
|
||||
|
@ -181,7 +192,8 @@ suite('ModelService', () => {
|
|||
].join('\n')
|
||||
));
|
||||
|
||||
const textBuffer = createTextBuffer(
|
||||
const textBuffer = createAndRegisterTextBuffer(
|
||||
disposables,
|
||||
[
|
||||
'package main', // 1
|
||||
'func foo() {', // 2
|
||||
|
@ -189,7 +201,7 @@ suite('ModelService', () => {
|
|||
''
|
||||
].join('\r\n'),
|
||||
DefaultEndOfLine.LF
|
||||
).textBuffer;
|
||||
);
|
||||
|
||||
const actual = ModelService._computeEdits(model, textBuffer);
|
||||
|
||||
|
@ -391,7 +403,7 @@ suite('ModelService', () => {
|
|||
|
||||
function assertComputeEdits(lines1: string[], lines2: string[]): void {
|
||||
const model = createTextModel(lines1.join('\n'));
|
||||
const textBuffer = createTextBuffer(lines2.join('\n'), DefaultEndOfLine.LF).textBuffer;
|
||||
const { disposable, textBuffer } = createTextBuffer(lines2.join('\n'), DefaultEndOfLine.LF);
|
||||
|
||||
// compute required edits
|
||||
// let start = Date.now();
|
||||
|
@ -402,6 +414,7 @@ function assertComputeEdits(lines1: string[], lines2: string[]): void {
|
|||
model.pushEditOperations([], edits, null);
|
||||
|
||||
assert.strictEqual(model.getValue(), lines2.join('\n'));
|
||||
disposable.dispose();
|
||||
model.dispose();
|
||||
}
|
||||
|
||||
|
@ -451,3 +464,9 @@ assertComputeEdits(file1, file2);
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createAndRegisterTextBuffer(store: DisposableStore, value: string | ITextBufferFactory | ITextSnapshot, defaultEOL: DefaultEndOfLine): ITextBuffer {
|
||||
const { disposable, textBuffer } = createTextBuffer(value, defaultEOL);
|
||||
store.add(disposable);
|
||||
return textBuffer;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,12 @@
|
|||
import * as assert from 'assert';
|
||||
import { IFullSemanticTokensDto, IDeltaSemanticTokensDto, encodeSemanticTokensDto, ISemanticTokensDto, decodeSemanticTokensDto } from 'vs/editor/common/services/semanticTokensDto';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
|
||||
suite('SemanticTokensDto', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function toArr(arr: Uint32Array): number[] {
|
||||
const result: number[] = [];
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import { createModelServices } from 'vs/editor/test/common/testTextModel';
|
|||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IThemeService, ITokenStyle } from 'vs/platform/theme/common/themeService';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
|
||||
suite('ModelService', () => {
|
||||
let disposables: DisposableStore;
|
||||
|
@ -28,6 +29,8 @@ suite('ModelService', () => {
|
|||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('issue #134973: invalid semantic tokens should be handled better', () => {
|
||||
const languageId = 'java';
|
||||
disposables.add(languageService.registerLanguage({ id: languageId }));
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { ColorZone, OverviewRulerZone, OverviewZoneManager } from 'vs/editor/common/viewModel/overviewZoneManager';
|
||||
|
||||
suite('Editor View - OverviewZoneManager', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('pixel ratio 1, dom height 600', () => {
|
||||
const LINE_COUNT = 50;
|
||||
const LINE_HEIGHT = 20;
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { DecorationSegment, LineDecoration, LineDecorationsNormalizer } from 'vs/editor/common/viewLayout/lineDecorations';
|
||||
import { InlineDecoration, InlineDecorationType } from 'vs/editor/common/viewModel';
|
||||
|
||||
suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Bug 9827:Overlapping inline decorations can cause wrong inline class to be applied', () => {
|
||||
|
||||
const result = LineDecorationsNormalizer.normalize('abcabcabcabcabcabcabcabcabcabc', [
|
||||
|
|
|
@ -3,10 +3,13 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { LinesLayout, EditorWhitespace } from 'vs/editor/common/viewLayout/linesLayout';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { EditorWhitespace, LinesLayout } from 'vs/editor/common/viewLayout/linesLayout';
|
||||
|
||||
suite('Editor ViewLayout - LinesLayout', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function insertWhitespace(linesLayout: LinesLayout, afterLineNumber: number, ordinal: number, heightInPx: number, minWidth: number): string {
|
||||
let id: string;
|
||||
linesLayout.changeWhitespace((accessor) => {
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
import * as assert from 'assert';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { IViewLineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { IViewLineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
|
||||
import { CharacterMapping, RenderLineInput, renderViewLine2 as renderViewLine, LineRange, DomPosition, RenderLineOutput2 } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { CharacterMapping, DomPosition, LineRange, RenderLineInput, RenderLineOutput2, renderViewLine2 as renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { InlineDecorationType } from 'vs/editor/common/viewModel';
|
||||
import { TestLineToken, TestLineTokens } from 'vs/editor/test/common/core/testLineToken';
|
||||
|
||||
|
@ -50,6 +51,8 @@ function inflateRenderLineOutput(renderLineOutput: RenderLineOutput2) {
|
|||
|
||||
suite('viewLineRenderer.renderLine', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function assertCharacterReplacement(lineContent: string, tabSize: number, expected: string, expectedCharOffsetInPart: number[]): void {
|
||||
const _actual = renderViewLine(new RenderLineInput(
|
||||
false,
|
||||
|
@ -966,6 +969,8 @@ function assertCharacterMapping3(actual: CharacterMapping, expectedInfo: Charact
|
|||
|
||||
suite('viewLineRenderer.renderLine 2', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function testCreateLineParts(fontIsMonospace: boolean, lineContent: string, tokens: TestLineToken[], fauxIndentLength: number, renderWhitespace: 'none' | 'boundary' | 'selection' | 'trailing' | 'all', selections: LineRange[] | null) {
|
||||
const actual = renderViewLine(new RenderLineInput(
|
||||
fontIsMonospace,
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { PositionAffinity } from 'vs/editor/common/model';
|
||||
import { ModelDecorationInjectedTextOptions } from 'vs/editor/common/model/textModel';
|
||||
import { ModelLineProjectionData } from 'vs/editor/common/modelLineProjectionData';
|
||||
|
||||
suite('Editor ViewModel - LineBreakData', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('Basic', () => {
|
||||
const data = new ModelLineProjectionData([], [], [100], [0], 10);
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { WrappingIndent, EditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/monospaceLineBreaksComputer';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { EditorOptions, WrappingIndent } from 'vs/editor/common/config/editorOptions';
|
||||
import { FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { ModelLineProjectionData, ILineBreaksComputerFactory } from 'vs/editor/common/modelLineProjectionData';
|
||||
import { ILineBreaksComputerFactory, ModelLineProjectionData } from 'vs/editor/common/modelLineProjectionData';
|
||||
import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/monospaceLineBreaksComputer';
|
||||
|
||||
function parseAnnotatedText(annotatedText: string): { text: string; indices: number[] } {
|
||||
let text = '';
|
||||
|
@ -80,6 +81,9 @@ function assertLineBreaks(factory: ILineBreaksComputerFactory, tabSize: number,
|
|||
}
|
||||
|
||||
suite('Editor ViewModel - MonospaceLineBreaksComputer', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('MonospaceLineBreaksComputer', () => {
|
||||
|
||||
const factory = new MonospaceLineBreaksComputerFactory('(', '\t).');
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { toUint32 } from 'vs/base/common/uint';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { PrefixSumComputer, PrefixSumIndexOfResult } from 'vs/editor/common/model/prefixSumComputer';
|
||||
|
||||
function toUint32Array(arr: number[]): Uint32Array {
|
||||
|
@ -18,6 +19,8 @@ function toUint32Array(arr: number[]): Uint32Array {
|
|||
|
||||
suite('Editor ViewModel - PrefixSumComputer', () => {
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('PrefixSumComputer', () => {
|
||||
let indexOfResult: PrefixSumIndexOfResult;
|
||||
|
||||
|
|
Loading…
Reference in a new issue