mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-14 12:11:43 +01:00
Organize imports
This commit is contained in:
@@ -9,7 +9,7 @@ import * as dom from 'vs/base/browser/dom';
|
||||
import {IPosition} from 'vs/editor/common/editorCommon';
|
||||
import {ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition} from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
class LightBulpWidget implements IContentWidget, IDisposable {
|
||||
export class LightBulpWidget implements IContentWidget, IDisposable {
|
||||
|
||||
private editor: ICodeEditor;
|
||||
private position: IPosition;
|
||||
@@ -70,4 +70,3 @@ class LightBulpWidget implements IContentWidget, IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
export = LightBulpWidget;
|
||||
|
||||
@@ -17,7 +17,7 @@ import {Range} from 'vs/editor/common/core/range';
|
||||
import {EventType, ICursorPositionChangedEvent, IModeSupportChangedEvent, IPosition, IRange} from 'vs/editor/common/editorCommon';
|
||||
import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
|
||||
import {IQuickFix2, QuickFixRegistry, getQuickFixes} from '../common/quickFix';
|
||||
import LightBulpWidget = require('./lightBulpWidget');
|
||||
import {LightBulpWidget} from './lightBulpWidget';
|
||||
|
||||
enum QuickFixSuggestState {
|
||||
NOT_ACTIVE = 0,
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {parse} from 'vs/base/common/json';
|
||||
import {readFile} from 'vs/base/node/pfs';
|
||||
import {PluginsRegistry} from 'vs/platform/plugins/common/pluginsRegistry';
|
||||
import pfs = require('vs/base/node/pfs');
|
||||
import json = require('vs/base/common/json');
|
||||
import {IRichEditConfiguration} from 'vs/editor/common/modes/supports/richEditSupport';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
|
||||
type CharacterPair = [string, string];
|
||||
|
||||
@@ -51,9 +51,9 @@ export class LanguageConfigurationFileHandler {
|
||||
}
|
||||
|
||||
private _handleConfigFile(modeId:string, configFilePath:string): void {
|
||||
pfs.readFile(configFilePath).then((fileContents) => {
|
||||
readFile(configFilePath).then((fileContents) => {
|
||||
var errors = [];
|
||||
var configuration = <ILanguageConfiguration>json.parse(fileContents.toString(), errors);
|
||||
var configuration = <ILanguageConfiguration>parse(fileContents.toString(), errors);
|
||||
if (errors.length) {
|
||||
console.error(nls.localize('parseErrors', "Errors parsing {0}: {1}", configFilePath, errors.join('\n')));
|
||||
}
|
||||
|
||||
@@ -5,17 +5,15 @@
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
import paths = require('vs/base/common/paths');
|
||||
import errors = require('vs/base/common/errors');
|
||||
|
||||
import * as Modes from 'vs/editor/common/modes';
|
||||
import supports = require('vs/editor/common/modes/supports');
|
||||
import collections = require('vs/base/common/collections');
|
||||
import textMate = require('vscode-textmate');
|
||||
import TMState = require('vs/editor/common/modes/TMState');
|
||||
import * as collections from 'vs/base/common/collections';
|
||||
import {onUnexpectedError} from 'vs/base/common/errors';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import {IMessageCollector, PluginsRegistry} from 'vs/platform/plugins/common/pluginsRegistry';
|
||||
import {Bracket, ILineTokens, IMode, IToken, ITokenizationSupport} from 'vs/editor/common/modes';
|
||||
import {TMState} from 'vs/editor/common/modes/TMState';
|
||||
import {Token} from 'vs/editor/common/modes/supports';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {PluginsRegistry, IMessageCollector} from 'vs/platform/plugins/common/pluginsRegistry';
|
||||
import {IGrammar, ITMToken, Registry} from 'vscode-textmate';
|
||||
|
||||
export interface ITMSyntaxExtensionPoint {
|
||||
language: string;
|
||||
@@ -48,7 +46,7 @@ let grammarsExtPoint = PluginsRegistry.registerExtensionPoint<ITMSyntaxExtension
|
||||
});
|
||||
|
||||
export class MainProcessTextMateSyntax {
|
||||
private _grammarRegistry: textMate.Registry;
|
||||
private _grammarRegistry: Registry;
|
||||
private _modeService: IModeService;
|
||||
private _scopeNameToFilePath: { [scopeName:string]: string; };
|
||||
|
||||
@@ -56,7 +54,7 @@ export class MainProcessTextMateSyntax {
|
||||
@IModeService modeService: IModeService
|
||||
) {
|
||||
this._modeService = modeService;
|
||||
this._grammarRegistry = new textMate.Registry({
|
||||
this._grammarRegistry = new Registry({
|
||||
getFilePath: (scopeName:string) => {
|
||||
return this._scopeNameToFilePath[scopeName];
|
||||
}
|
||||
@@ -105,44 +103,44 @@ export class MainProcessTextMateSyntax {
|
||||
public registerDefinition(modeId: string, scopeName: string): void {
|
||||
this._grammarRegistry.loadGrammar(scopeName, (err, grammar) => {
|
||||
if (err) {
|
||||
errors.onUnexpectedError(err);
|
||||
onUnexpectedError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
this._modeService.registerTokenizationSupport(modeId, (mode: Modes.IMode) => {
|
||||
this._modeService.registerTokenizationSupport(modeId, (mode: IMode) => {
|
||||
return createTokenizationSupport(mode, grammar);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function createTokenizationSupport(mode: Modes.IMode, grammar: textMate.IGrammar): Modes.ITokenizationSupport {
|
||||
function createTokenizationSupport(mode: IMode, grammar: IGrammar): ITokenizationSupport {
|
||||
var tokenizer = new Tokenizer(mode.getId(), grammar);
|
||||
return {
|
||||
shouldGenerateEmbeddedModels: false,
|
||||
getInitialState: () => new TMState.TMState(mode, null, null),
|
||||
tokenize: (line, state, offsetDelta?, stopAtOffset?) => tokenizer.tokenize(line, <TMState.TMState> state, offsetDelta, stopAtOffset)
|
||||
getInitialState: () => new TMState(mode, null, null),
|
||||
tokenize: (line, state, offsetDelta?, stopAtOffset?) => tokenizer.tokenize(line, <TMState> state, offsetDelta, stopAtOffset)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Tokenizer {
|
||||
private _grammar: textMate.IGrammar;
|
||||
private _grammar: IGrammar;
|
||||
private _modeId: string;
|
||||
|
||||
constructor(modeId:string, grammar: textMate.IGrammar) {
|
||||
constructor(modeId:string, grammar: IGrammar) {
|
||||
this._modeId = modeId;
|
||||
this._grammar = grammar;
|
||||
}
|
||||
|
||||
public tokenize(line: string, state: TMState.TMState, offsetDelta: number = 0, stopAtOffset?: number): Modes.ILineTokens {
|
||||
public tokenize(line: string, state: TMState, offsetDelta: number = 0, stopAtOffset?: number): ILineTokens {
|
||||
if (line.length >= 20000) {
|
||||
return {
|
||||
tokens: <Modes.IToken[]>[{
|
||||
tokens: <IToken[]>[{
|
||||
startIndex: offsetDelta,
|
||||
type: '',
|
||||
bracket: Modes.Bracket.None
|
||||
bracket: Bracket.None
|
||||
}],
|
||||
actualStopOffset: offsetDelta,
|
||||
endState: state,
|
||||
@@ -155,7 +153,7 @@ class Tokenizer {
|
||||
|
||||
// Create the result early and fill in the tokens later
|
||||
let ret = {
|
||||
tokens: <Modes.IToken[]>[],
|
||||
tokens: <IToken[]>[],
|
||||
actualStopOffset: offsetDelta + line.length,
|
||||
endState: freshState,
|
||||
modeTransitions: [{ startIndex: offsetDelta, mode: freshState.getMode() }],
|
||||
@@ -170,7 +168,7 @@ class Tokenizer {
|
||||
|
||||
if (t.isOpaqueToken) {
|
||||
// Should not do any smartness to detect brackets on this token
|
||||
ret.tokens.push(new supports.Token(tokenStartIndex + offsetDelta, t.tokenType));
|
||||
ret.tokens.push(new Token(tokenStartIndex + offsetDelta, t.tokenType));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -206,19 +204,19 @@ class Tokenizer {
|
||||
if (isBracket) {
|
||||
if (tokenStartIndex < i) {
|
||||
// push a token before character `i`
|
||||
ret.tokens.push(new supports.Token(tokenStartIndex + offsetDelta, t.tokenType));
|
||||
ret.tokens.push(new Token(tokenStartIndex + offsetDelta, t.tokenType));
|
||||
tokenStartIndex = i;
|
||||
}
|
||||
|
||||
// push character `i` as a token
|
||||
ret.tokens.push(new supports.Token(tokenStartIndex + offsetDelta, isBracket + '.' + t.modeToken));
|
||||
ret.tokens.push(new Token(tokenStartIndex + offsetDelta, isBracket + '.' + t.modeToken));
|
||||
tokenStartIndex = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (tokenStartIndex < tokenEndIndex) {
|
||||
// push the remaining text as a token
|
||||
ret.tokens.push(new supports.Token(tokenStartIndex + offsetDelta, t.tokenType));
|
||||
ret.tokens.push(new Token(tokenStartIndex + offsetDelta, t.tokenType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +224,7 @@ class Tokenizer {
|
||||
}
|
||||
}
|
||||
|
||||
function decodeTextMateToken(modeId:string, entry: textMate.IToken) {
|
||||
function decodeTextMateToken(modeId:string, entry: ITMToken) {
|
||||
let tokenTypeArray: string[] = [];
|
||||
for (let level = 1 /* deliberately skip scope 0*/; level < entry.scopes.length; ++level) {
|
||||
tokenTypeArray = tokenTypeArray.concat(entry.scopes[level].split('.'));
|
||||
@@ -289,9 +287,9 @@ var _openSquare = '['.charCodeAt(0);
|
||||
var _closeSquare = ']'.charCodeAt(0);
|
||||
|
||||
var characterToBracket = collections.createNumberDictionary<number>();
|
||||
characterToBracket['('.charCodeAt(0)] = Modes.Bracket.Open;
|
||||
characterToBracket[')'.charCodeAt(0)] = Modes.Bracket.Close;
|
||||
characterToBracket['{'.charCodeAt(0)] = Modes.Bracket.Open;
|
||||
characterToBracket['}'.charCodeAt(0)] = Modes.Bracket.Close;
|
||||
characterToBracket['['.charCodeAt(0)] = Modes.Bracket.Open;
|
||||
characterToBracket[']'.charCodeAt(0)] = Modes.Bracket.Close;
|
||||
characterToBracket['('.charCodeAt(0)] = Bracket.Open;
|
||||
characterToBracket[')'.charCodeAt(0)] = Bracket.Close;
|
||||
characterToBracket['{'.charCodeAt(0)] = Bracket.Open;
|
||||
characterToBracket['}'.charCodeAt(0)] = Bracket.Close;
|
||||
characterToBracket['['.charCodeAt(0)] = Bracket.Open;
|
||||
characterToBracket[']'.charCodeAt(0)] = Bracket.Close;
|
||||
+2
-2
@@ -56,14 +56,14 @@ export interface IGrammar {
|
||||
}
|
||||
|
||||
export interface ITokenizeLineResult {
|
||||
tokens: IToken[];
|
||||
tokens: ITMToken[];
|
||||
/**
|
||||
* The `prevState` to be passed on to the next line tokenization.
|
||||
*/
|
||||
ruleStack: StackElement[];
|
||||
}
|
||||
|
||||
export interface IToken {
|
||||
export interface ITMToken {
|
||||
startIndex: number;
|
||||
endIndex: number;
|
||||
scopes: string[];
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import {ILanguageDef} from './types';
|
||||
|
||||
import 'vs/languages/json/common/json.contribution';
|
||||
|
||||
this.MonacoEditorLanguages = this.MonacoEditorLanguages || [];
|
||||
let MonacoEditorLanguages: ILanguageDef[] = this.MonacoEditorLanguages;
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/bat');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/bat';
|
||||
import {testOnEnter, testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
T.testTokenization('bat', languageDef.language, [
|
||||
testTokenization('bat', language, [
|
||||
// support.functions
|
||||
[{
|
||||
line: '@echo off title Selfhost',
|
||||
@@ -333,7 +333,7 @@ T.testTokenization('bat', languageDef.language, [
|
||||
]}]
|
||||
]);
|
||||
|
||||
T.testOnEnter('bat', languageDef.language, (assertOnEnter) => {
|
||||
testOnEnter('bat', language, (assertOnEnter) => {
|
||||
assertOnEnter.nothing('', ' a', '');
|
||||
assertOnEnter.indents('', ' {', '');
|
||||
assertOnEnter.indents('', '( ', '');
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/coffee');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/coffee';
|
||||
import {testOnEnter, testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testOnEnter('coffeescript', languageDef.language, (assertOnEnter) => {
|
||||
testOnEnter('coffeescript', language, (assertOnEnter) => {
|
||||
assertOnEnter.nothing('', ' a', '');
|
||||
assertOnEnter.indents('', ' {', '');
|
||||
assertOnEnter.indents('', '( ', '');
|
||||
@@ -21,7 +21,7 @@ T.testOnEnter('coffeescript', languageDef.language, (assertOnEnter) => {
|
||||
assertOnEnter.indentsOutdents('', ' { ', ' } ');
|
||||
});
|
||||
|
||||
T.testTokenization('coffeescript', languageDef.language, [
|
||||
testTokenization('coffeescript', language, [
|
||||
// Comments
|
||||
[{
|
||||
line: '#',
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/cpp');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/cpp';
|
||||
import {testOnEnter, testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testOnEnter('cpp', languageDef.language, (assertOnEnter) => {
|
||||
testOnEnter('cpp', language, (assertOnEnter) => {
|
||||
assertOnEnter.nothing('', ' a', '');
|
||||
assertOnEnter.indents('', ' <', '');
|
||||
assertOnEnter.indents('', ' {', '');
|
||||
@@ -22,7 +22,7 @@ T.testOnEnter('cpp', languageDef.language, (assertOnEnter) => {
|
||||
assertOnEnter.indentsOutdents('', ' { ', ' } ');
|
||||
});
|
||||
|
||||
T.testTokenization('cpp', languageDef.language, [
|
||||
testTokenization('cpp', language, [
|
||||
// Keywords
|
||||
[{
|
||||
line: 'int _tmain(int argc, _TCHAR* argv[])',
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/csharp');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/csharp';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testTokenization('csharp', languageDef.language, [
|
||||
testTokenization('csharp', language, [
|
||||
|
||||
// Generated from sample
|
||||
[{
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/dockerfile');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/dockerfile';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
T.testTokenization('dockerfile', languageDef.language, [
|
||||
testTokenization('dockerfile', language, [
|
||||
// All
|
||||
[{
|
||||
line: 'FROM mono:3.12',
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/fsharp');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/fsharp';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
T.testTokenization('fsharp', languageDef.language, [
|
||||
testTokenization('fsharp', language, [
|
||||
// comments - single line
|
||||
[{
|
||||
line: '// one line comment',
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/go');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/go';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testTokenization('go', languageDef.language, [
|
||||
testTokenization('go', language, [
|
||||
// Tests
|
||||
[{
|
||||
line: '/* Block comment. */',
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/jade');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/jade';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testTokenization('jade', languageDef.language, [
|
||||
testTokenization('jade', language, [
|
||||
// Tags [Jade]
|
||||
[{
|
||||
line: 'p 5',
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import languageDef = require('vs/editor/standalone-languages/java');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import * as assert from 'assert';
|
||||
import {language} from 'vs/editor/standalone-languages/java';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testTokenization('java', languageDef.language, [
|
||||
testTokenization('java', language, [
|
||||
// Comments - single line
|
||||
[{
|
||||
line: '//',
|
||||
@@ -612,7 +612,7 @@ T.testTokenization('java', languageDef.language, [
|
||||
|
||||
suite('java', () => {
|
||||
test('word definition', () => {
|
||||
var wordDefinition = languageDef.language.wordDefinition;
|
||||
var wordDefinition = language.wordDefinition;
|
||||
assert.deepEqual('a b cde'.match(wordDefinition), ['a', 'b', 'cde']);
|
||||
|
||||
assert.deepEqual('public static void main(String[] args) {'.match(wordDefinition),
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/lua');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/lua';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
T.testTokenization('lua', languageDef.language, [
|
||||
testTokenization('lua', language, [
|
||||
|
||||
// Keywords
|
||||
[{
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/objective-c');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/objective-c';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
T.testTokenization('objective-c', languageDef.language, [
|
||||
testTokenization('objective-c', language, [
|
||||
// Keywords
|
||||
[{
|
||||
line: '-(id) initWithParams:(id<anObject>) aHandler withDeviceStateManager:(id<anotherObject>) deviceStateManager',
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import languageDef = require('vs/editor/standalone-languages/powershell');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import * as assert from 'assert';
|
||||
import {language} from 'vs/editor/standalone-languages/powershell';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testTokenization('powershell', languageDef.language, [
|
||||
testTokenization('powershell', language, [
|
||||
// Comments - single line
|
||||
[{
|
||||
line: '#',
|
||||
@@ -744,7 +744,7 @@ T.testTokenization('powershell', languageDef.language, [
|
||||
|
||||
suite('powershell', () => {
|
||||
test('word definition', () => {
|
||||
var wordDefinition = languageDef.language.wordDefinition;
|
||||
var wordDefinition = language.wordDefinition;
|
||||
assert.deepEqual('a b cde'.match(wordDefinition), ['a', 'b', 'cde']);
|
||||
assert.deepEqual('if ($parameterSet["class"] -eq "blank")'.match(wordDefinition), ['if', '$parameterSet', 'class', '-eq', 'blank']);
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/python');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/python';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
T.testTokenization('python', languageDef.language, [
|
||||
testTokenization('python', language, [
|
||||
// Keywords
|
||||
[{
|
||||
line: 'def func():',
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/r');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/r';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
T.testTokenization('r', languageDef.language, [
|
||||
testTokenization('r', language, [
|
||||
// Keywords
|
||||
[{
|
||||
line: 'function(a) { a }',
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/ruby');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/ruby';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testTokenization('ruby', languageDef.language, [
|
||||
testTokenization('ruby', language, [
|
||||
// Keywords
|
||||
[{
|
||||
line: 'class Klass def init() end',
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/sql');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/sql';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testTokenization('sql', languageDef.language, [
|
||||
testTokenization('sql', language, [
|
||||
// Comments
|
||||
[{
|
||||
line: '-- a comment',
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/swift');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {language} from 'vs/editor/standalone-languages/swift';
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
|
||||
T.testTokenization('swift', languageDef.language, [
|
||||
testTokenization('swift', language, [
|
||||
|
||||
// Attributes
|
||||
[{
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import types = require('../types');
|
||||
import modesUtil = require('vs/editor/test/common/modesUtil');
|
||||
import monarchCompile = require('vs/editor/common/modes/monarch/monarchCompile');
|
||||
import MonarchDefinition = require('vs/editor/common/modes/monarch/monarchDefinition');
|
||||
import {compile} from 'vs/editor/common/modes/monarch/monarchCompile';
|
||||
import {createRichEditSupport} from 'vs/editor/common/modes/monarch/monarchDefinition';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
|
||||
import {createOnEnterAsserter, executeMonarchTokenizationTests} from 'vs/editor/test/common/modesUtil';
|
||||
import {ILanguage} from '../types';
|
||||
|
||||
export enum Bracket {
|
||||
None = 0,
|
||||
@@ -34,20 +34,20 @@ export interface IOnEnterAsserter {
|
||||
indentsOutdents(oneLineAboveText:string, beforeText:string, afterText:string): void;
|
||||
}
|
||||
|
||||
export function testTokenization(name:string, language: types.ILanguage, tests:ITestItem[][]): void {
|
||||
export function testTokenization(name:string, language: ILanguage, tests:ITestItem[][]): void {
|
||||
suite(language.displayName || name, () => {
|
||||
test('Tokenization', () => {
|
||||
modesUtil.executeMonarchTokenizationTests(name, language, <any>tests);
|
||||
executeMonarchTokenizationTests(name, language, <any>tests);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function testOnEnter(name:string, language: types.ILanguage, callback:(assertOnEnter: IOnEnterAsserter)=>void): void {
|
||||
export function testOnEnter(name:string, language: ILanguage, callback:(assertOnEnter: IOnEnterAsserter)=>void): void {
|
||||
suite(language.displayName || name, () => {
|
||||
test('onEnter', () => {
|
||||
var lexer = monarchCompile.compile(language);
|
||||
var richEditSupport = new RichEditSupport('test', MonarchDefinition.createRichEditSupport(lexer));
|
||||
callback(modesUtil.createOnEnterAsserter('test', richEditSupport));
|
||||
var lexer = compile(language);
|
||||
var richEditSupport = new RichEditSupport('test', createRichEditSupport(lexer));
|
||||
callback(createOnEnterAsserter('test', richEditSupport));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/vb');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
import {language} from 'vs/editor/standalone-languages/vb';
|
||||
|
||||
T.testTokenization('vb', languageDef.language, [
|
||||
testTokenization('vb', language, [
|
||||
|
||||
// Comments - single line
|
||||
[{
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import languageDef = require('vs/editor/standalone-languages/xml');
|
||||
import T = require('vs/editor/standalone-languages/test/testUtil');
|
||||
import {testTokenization} from 'vs/editor/standalone-languages/test/testUtil';
|
||||
import {language} from 'vs/editor/standalone-languages/xml';
|
||||
|
||||
var Bracket = {
|
||||
Open: 1,
|
||||
Close: -1
|
||||
};
|
||||
|
||||
T.testTokenization('xml', languageDef.language, [
|
||||
testTokenization('xml', language, [
|
||||
// Complete Start Tag with Whitespace
|
||||
[{
|
||||
line: '<person>',
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import * as assert from 'assert';
|
||||
import {Cursor} from 'vs/editor/common/controller/cursor';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
import {Cursor} from 'vs/editor/common/controller/cursor';
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import {IMode} from 'vs/editor/common/modes';
|
||||
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
|
||||
|
||||
@@ -17,7 +17,7 @@ export function testCommand(
|
||||
lines: string[],
|
||||
mode: IMode,
|
||||
selection: Selection,
|
||||
commandFactory: (selection:Selection) => EditorCommon.ICommand,
|
||||
commandFactory: (selection:Selection) => editorCommon.ICommand,
|
||||
expectedLines: string[],
|
||||
expectedSelection: Selection
|
||||
): void {
|
||||
@@ -28,7 +28,7 @@ export function testCommand(
|
||||
|
||||
cursor.setSelections('tests', [selection]);
|
||||
|
||||
cursor.configuration.handlerDispatcher.trigger('tests', EditorCommon.Handler.ExecuteCommand, commandFactory(cursor.getSelection()));
|
||||
cursor.configuration.handlerDispatcher.trigger('tests', editorCommon.Handler.ExecuteCommand, commandFactory(cursor.getSelection()));
|
||||
|
||||
let actualValue = model.toRawText().lines;
|
||||
assert.deepEqual(actualValue, expectedLines);
|
||||
@@ -44,10 +44,10 @@ export function testCommand(
|
||||
/**
|
||||
* Extract edit operations if command `command` were to execute on model `model`
|
||||
*/
|
||||
export function getEditOperation(model: EditorCommon.IModel, command: EditorCommon.ICommand): EditorCommon.IIdentifiedSingleEditOperation[] {
|
||||
var operations: EditorCommon.IIdentifiedSingleEditOperation[] = [];
|
||||
var editOperationBuilder: EditorCommon.IEditOperationBuilder = {
|
||||
addEditOperation: (range: EditorCommon.IEditorRange, text: string) => {
|
||||
export function getEditOperation(model: editorCommon.IModel, command: editorCommon.ICommand): editorCommon.IIdentifiedSingleEditOperation[] {
|
||||
var operations: editorCommon.IIdentifiedSingleEditOperation[] = [];
|
||||
var editOperationBuilder: editorCommon.IEditOperationBuilder = {
|
||||
addEditOperation: (range: editorCommon.IEditorRange, text: string) => {
|
||||
operations.push({
|
||||
identifier: null,
|
||||
range: range,
|
||||
@@ -56,7 +56,7 @@ export function getEditOperation(model: EditorCommon.IModel, command: EditorComm
|
||||
});
|
||||
},
|
||||
|
||||
trackSelection: (selection: EditorCommon.IEditorSelection) => {
|
||||
trackSelection: (selection: editorCommon.IEditorSelection) => {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -67,7 +67,7 @@ export function getEditOperation(model: EditorCommon.IModel, command: EditorComm
|
||||
/**
|
||||
* Create single edit operation
|
||||
*/
|
||||
export function createSingleEditOp(text:string, positionLineNumber:number, positionColumn:number, selectionLineNumber:number = positionLineNumber, selectionColumn:number = positionColumn):EditorCommon.IIdentifiedSingleEditOperation {
|
||||
export function createSingleEditOp(text:string, positionLineNumber:number, positionColumn:number, selectionLineNumber:number = positionLineNumber, selectionColumn:number = positionColumn):editorCommon.IIdentifiedSingleEditOperation {
|
||||
return {
|
||||
identifier: null,
|
||||
range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn),
|
||||
@@ -79,7 +79,7 @@ export function createSingleEditOp(text:string, positionLineNumber:number, posit
|
||||
/**
|
||||
* Create single edit operation
|
||||
*/
|
||||
export function createInsertDeleteSingleEditOp(text:string, positionLineNumber:number, positionColumn:number, selectionLineNumber:number = positionLineNumber, selectionColumn:number = positionColumn):EditorCommon.IIdentifiedSingleEditOperation {
|
||||
export function createInsertDeleteSingleEditOp(text:string, positionLineNumber:number, positionColumn:number, selectionLineNumber:number = positionLineNumber, selectionColumn:number = positionColumn):editorCommon.IIdentifiedSingleEditOperation {
|
||||
return {
|
||||
identifier: null,
|
||||
range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn),
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import TU = require('vs/editor/test/common/commands/commandTestUtils');
|
||||
import * as assert from 'assert';
|
||||
import {ShiftCommand} from 'vs/editor/common/commands/shiftCommand';
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import {withEditorModel} from 'vs/editor/test/common/editorTestUtils';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
import * as Modes from 'vs/editor/common/modes';
|
||||
import {IIdentifiedSingleEditOperation} from 'vs/editor/common/editorCommon';
|
||||
import {IMode, IRichEditSupport, IndentAction} from 'vs/editor/common/modes';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
|
||||
import {createSingleEditOp, getEditOperation, testCommand} from 'vs/editor/test/common/commands/commandTestUtils';
|
||||
import {withEditorModel} from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
function testShiftCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
TU.testCommand(lines, null, selection, (sel) => new ShiftCommand(sel, {
|
||||
testCommand(lines, null, selection, (sel) => new ShiftCommand(sel, {
|
||||
isUnshift: false,
|
||||
tabSize: 4,
|
||||
oneIndent: '\t'
|
||||
@@ -22,16 +22,16 @@ function testShiftCommand(lines: string[], selection: Selection, expectedLines:
|
||||
}
|
||||
|
||||
function testUnshiftCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
TU.testCommand(lines, null, selection, (sel) => new ShiftCommand(sel, {
|
||||
testCommand(lines, null, selection, (sel) => new ShiftCommand(sel, {
|
||||
isUnshift: true,
|
||||
tabSize: 4,
|
||||
oneIndent: '\t'
|
||||
}), expectedLines, expectedSelection);
|
||||
}
|
||||
|
||||
class DocBlockCommentMode implements Modes.IMode {
|
||||
class DocBlockCommentMode implements IMode {
|
||||
|
||||
public richEditSupport: Modes.IRichEditSupport;
|
||||
public richEditSupport: IRichEditSupport;
|
||||
|
||||
constructor() {
|
||||
this.richEditSupport = new RichEditSupport(this.getId(), {
|
||||
@@ -46,22 +46,22 @@ class DocBlockCommentMode implements Modes.IMode {
|
||||
// e.g. /** | */
|
||||
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
|
||||
afterText: /^\s*\*\/$/,
|
||||
action: { indentAction: Modes.IndentAction.IndentOutdent, appendText: ' * ' }
|
||||
action: { indentAction: IndentAction.IndentOutdent, appendText: ' * ' }
|
||||
},
|
||||
{
|
||||
// e.g. /** ...|
|
||||
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
|
||||
action: { indentAction: Modes.IndentAction.None, appendText: ' * ' }
|
||||
action: { indentAction: IndentAction.None, appendText: ' * ' }
|
||||
},
|
||||
{
|
||||
// e.g. * ...|
|
||||
beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
|
||||
action: { indentAction: Modes.IndentAction.None, appendText: '* ' }
|
||||
action: { indentAction: IndentAction.None, appendText: '* ' }
|
||||
},
|
||||
{
|
||||
// e.g. */|
|
||||
beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
|
||||
action: { indentAction: Modes.IndentAction.None, removeText: 1 }
|
||||
action: { indentAction: IndentAction.None, removeText: 1 }
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -71,14 +71,14 @@ class DocBlockCommentMode implements Modes.IMode {
|
||||
return 'docBlockCommentMode';
|
||||
}
|
||||
|
||||
public toSimplifiedMode(): Modes.IMode {
|
||||
public toSimplifiedMode(): IMode {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function testShiftCommandInDocBlockCommentMode(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
TU.testCommand(lines, new DocBlockCommentMode(), selection, (sel) => new ShiftCommand(sel, {
|
||||
testCommand(lines, new DocBlockCommentMode(), selection, (sel) => new ShiftCommand(sel, {
|
||||
isUnshift: false,
|
||||
tabSize: 4,
|
||||
oneIndent: '\t'
|
||||
@@ -86,7 +86,7 @@ function testShiftCommandInDocBlockCommentMode(lines: string[], selection: Selec
|
||||
}
|
||||
|
||||
function testUnshiftCommandInDocBlockCommentMode(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
TU.testCommand(lines, new DocBlockCommentMode(), selection, (sel) => new ShiftCommand(sel, {
|
||||
testCommand(lines, new DocBlockCommentMode(), selection, (sel) => new ShiftCommand(sel, {
|
||||
isUnshift: true,
|
||||
tabSize: 4,
|
||||
oneIndent: '\t'
|
||||
@@ -629,7 +629,7 @@ suite('Editor Commands - ShiftCommand', () => {
|
||||
var testOutdent = (tabSize: number, oneIndent: string, lineText:string, expectedIndents:number) => {
|
||||
var expectedIndent = repeatStr(oneIndent, expectedIndents);
|
||||
if (lineText.length > 0) {
|
||||
_assertUnshiftCommand(tabSize, oneIndent, [lineText + 'aaa'], [TU.createSingleEditOp(expectedIndent, 1, 1, 1, lineText.length + 1)]);
|
||||
_assertUnshiftCommand(tabSize, oneIndent, [lineText + 'aaa'], [createSingleEditOp(expectedIndent, 1, 1, 1, lineText.length + 1)]);
|
||||
} else {
|
||||
_assertUnshiftCommand(tabSize, oneIndent, [lineText + 'aaa'], []);
|
||||
}
|
||||
@@ -637,7 +637,7 @@ suite('Editor Commands - ShiftCommand', () => {
|
||||
|
||||
var testIndent = (tabSize: number, oneIndent: string, lineText:string, expectedIndents:number) => {
|
||||
var expectedIndent = repeatStr(oneIndent, expectedIndents);
|
||||
_assertShiftCommand(tabSize, oneIndent, [lineText + 'aaa'], [TU.createSingleEditOp(expectedIndent, 1, 1, 1, lineText.length + 1)]);
|
||||
_assertShiftCommand(tabSize, oneIndent, [lineText + 'aaa'], [createSingleEditOp(expectedIndent, 1, 1, 1, lineText.length + 1)]);
|
||||
};
|
||||
|
||||
var testIndentation = (tabSize: number, lineText:string, expectedOnOutdent:number, expectedOnIndent:number) => {
|
||||
@@ -714,26 +714,26 @@ suite('Editor Commands - ShiftCommand', () => {
|
||||
|
||||
});
|
||||
|
||||
function _assertUnshiftCommand(tabSize:number, oneIndent:string, text:string[], expected:EditorCommon.IIdentifiedSingleEditOperation[]): void {
|
||||
function _assertUnshiftCommand(tabSize:number, oneIndent:string, text:string[], expected:IIdentifiedSingleEditOperation[]): void {
|
||||
return withEditorModel(text, (model) => {
|
||||
var op = new ShiftCommand(new Selection(1,1,text.length+1,1), {
|
||||
isUnshift: true,
|
||||
tabSize: tabSize,
|
||||
oneIndent: oneIndent
|
||||
});
|
||||
var actual = TU.getEditOperation(model, op);
|
||||
var actual = getEditOperation(model, op);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
}
|
||||
|
||||
function _assertShiftCommand(tabSize:number, oneIndent:string, text:string[], expected:EditorCommon.IIdentifiedSingleEditOperation[]): void {
|
||||
function _assertShiftCommand(tabSize:number, oneIndent:string, text:string[], expected:IIdentifiedSingleEditOperation[]): void {
|
||||
return withEditorModel(text, (model) => {
|
||||
var op = new ShiftCommand(new Selection(1,1,text.length+1,1), {
|
||||
isUnshift: false,
|
||||
tabSize: tabSize,
|
||||
oneIndent: oneIndent
|
||||
});
|
||||
var actual = TU.getEditOperation(model, op);
|
||||
var actual = getEditOperation(model, op);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import * as assert from 'assert';
|
||||
import {Cursor} from 'vs/editor/common/controller/cursor';
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
|
||||
import {EditOperation} from 'vs/editor/common/core/editOperation';
|
||||
import {ModelLine, ILineEdit} from 'vs/editor/common/model/modelLine';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
import {IIdentifiedSingleEditOperation} from 'vs/editor/common/editorCommon';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import {ILineEdit, ModelLine} from 'vs/editor/common/model/modelLine';
|
||||
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
|
||||
|
||||
function testCommand(lines:string[], selection:Selection, edits:EditorCommon.IIdentifiedSingleEditOperation[], expectedLines:string[], expectedSelection:Selection): void {
|
||||
function testCommand(lines:string[], selection:Selection, edits:IIdentifiedSingleEditOperation[], expectedLines:string[], expectedSelection:Selection): void {
|
||||
let model = new Model(lines.join('\n'), null);
|
||||
let config = new MockConfiguration(null);
|
||||
let cursor = new Cursor(0, config, model, null, false);
|
||||
|
||||
@@ -4,25 +4,24 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import TU = require('vs/editor/test/common/commands/commandTestUtils');
|
||||
import TrimTrailingWhitespaceCommand = require('vs/editor/common/commands/trimTrailingWhitespaceCommand');
|
||||
import * as assert from 'assert';
|
||||
import {TrimTrailingWhitespaceCommand, trimTrailingWhitespace} from 'vs/editor/common/commands/trimTrailingWhitespaceCommand';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
import {IIdentifiedSingleEditOperation, IPosition} from 'vs/editor/common/editorCommon';
|
||||
import {createInsertDeleteSingleEditOp, createSingleEditOp, getEditOperation} from 'vs/editor/test/common/commands/commandTestUtils';
|
||||
import {pos, withEditorModel} from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
function assertTrimTrailingWhitespaceCommand(text:string[], expected:EditorCommon.IIdentifiedSingleEditOperation[]): void {
|
||||
function assertTrimTrailingWhitespaceCommand(text:string[], expected:IIdentifiedSingleEditOperation[]): void {
|
||||
return withEditorModel(text, (model) => {
|
||||
var op = new TrimTrailingWhitespaceCommand.TrimTrailingWhitespaceCommand(Selection.createSelection(1,1,1,1));
|
||||
var actual = TU.getEditOperation(model, op);
|
||||
var op = new TrimTrailingWhitespaceCommand(Selection.createSelection(1,1,1,1));
|
||||
var actual = getEditOperation(model, op);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
}
|
||||
|
||||
function assertTrimTrailingWhitespace(text:string[], cursors:EditorCommon.IPosition[], expected:EditorCommon.IIdentifiedSingleEditOperation[]): void {
|
||||
function assertTrimTrailingWhitespace(text:string[], cursors:IPosition[], expected:IIdentifiedSingleEditOperation[]): void {
|
||||
return withEditorModel(text, (model) => {
|
||||
var actual = TrimTrailingWhitespaceCommand.trimTrailingWhitespace(model, cursors);
|
||||
var actual = trimTrailingWhitespace(model, cursors);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
}
|
||||
@@ -32,10 +31,10 @@ suite('Editor Commands - Trim Trailing Whitespace Command', () => {
|
||||
test('remove trailing whitespace', function () {
|
||||
assertTrimTrailingWhitespaceCommand([''], []);
|
||||
assertTrimTrailingWhitespaceCommand(['text'], []);
|
||||
assertTrimTrailingWhitespaceCommand(['text '], [TU.createSingleEditOp(null, 1, 5, 1, 8)]);
|
||||
assertTrimTrailingWhitespaceCommand(['text\t '], [TU.createSingleEditOp(null, 1, 5, 1, 9)]);
|
||||
assertTrimTrailingWhitespaceCommand(['\t '], [TU.createSingleEditOp(null, 1, 1, 1, 5)]);
|
||||
assertTrimTrailingWhitespaceCommand(['text\t'], [TU.createSingleEditOp(null, 1, 5, 1, 6)]);
|
||||
assertTrimTrailingWhitespaceCommand(['text '], [createSingleEditOp(null, 1, 5, 1, 8)]);
|
||||
assertTrimTrailingWhitespaceCommand(['text\t '], [createSingleEditOp(null, 1, 5, 1, 9)]);
|
||||
assertTrimTrailingWhitespaceCommand(['\t '], [createSingleEditOp(null, 1, 1, 1, 5)]);
|
||||
assertTrimTrailingWhitespaceCommand(['text\t'], [createSingleEditOp(null, 1, 5, 1, 6)]);
|
||||
assertTrimTrailingWhitespaceCommand([
|
||||
'some text\t',
|
||||
'some more text',
|
||||
@@ -43,16 +42,16 @@ suite('Editor Commands - Trim Trailing Whitespace Command', () => {
|
||||
'even more text ',
|
||||
'and some mixed\t \t'
|
||||
], [
|
||||
TU.createSingleEditOp(null, 1, 10, 1, 11),
|
||||
TU.createSingleEditOp(null, 3, 1, 3, 4),
|
||||
TU.createSingleEditOp(null, 4, 15, 4, 17),
|
||||
TU.createSingleEditOp(null, 5, 15, 5, 20)
|
||||
createSingleEditOp(null, 1, 10, 1, 11),
|
||||
createSingleEditOp(null, 3, 1, 3, 4),
|
||||
createSingleEditOp(null, 4, 15, 4, 17),
|
||||
createSingleEditOp(null, 5, 15, 5, 20)
|
||||
]);
|
||||
|
||||
|
||||
assertTrimTrailingWhitespace(['text '], [pos(1,1), pos(1,2), pos(1,3)], [TU.createInsertDeleteSingleEditOp(null, 1, 5, 1, 8)]);
|
||||
assertTrimTrailingWhitespace(['text '], [pos(1,1), pos(1,5)], [TU.createInsertDeleteSingleEditOp(null, 1, 5, 1, 8)]);
|
||||
assertTrimTrailingWhitespace(['text '], [pos(1,1), pos(1,5), pos(1,6)], [TU.createInsertDeleteSingleEditOp(null, 1, 6, 1, 8)]);
|
||||
assertTrimTrailingWhitespace(['text '], [pos(1,1), pos(1,2), pos(1,3)], [createInsertDeleteSingleEditOp(null, 1, 5, 1, 8)]);
|
||||
assertTrimTrailingWhitespace(['text '], [pos(1,1), pos(1,5)], [createInsertDeleteSingleEditOp(null, 1, 5, 1, 8)]);
|
||||
assertTrimTrailingWhitespace(['text '], [pos(1,1), pos(1,5), pos(1,6)], [createInsertDeleteSingleEditOp(null, 1, 6, 1, 8)]);
|
||||
assertTrimTrailingWhitespace([
|
||||
'some text\t',
|
||||
'some more text',
|
||||
@@ -60,10 +59,10 @@ suite('Editor Commands - Trim Trailing Whitespace Command', () => {
|
||||
'even more text ',
|
||||
'and some mixed\t \t'
|
||||
], [], [
|
||||
TU.createInsertDeleteSingleEditOp(null, 1, 10, 1, 11),
|
||||
TU.createInsertDeleteSingleEditOp(null, 3, 1, 3, 4),
|
||||
TU.createInsertDeleteSingleEditOp(null, 4, 15, 4, 17),
|
||||
TU.createInsertDeleteSingleEditOp(null, 5, 15, 5, 20)
|
||||
createInsertDeleteSingleEditOp(null, 1, 10, 1, 11),
|
||||
createInsertDeleteSingleEditOp(null, 3, 1, 3, 4),
|
||||
createInsertDeleteSingleEditOp(null, 4, 15, 4, 17),
|
||||
createInsertDeleteSingleEditOp(null, 5, 15, 5, 20)
|
||||
]);
|
||||
assertTrimTrailingWhitespace([
|
||||
'some text\t',
|
||||
@@ -72,9 +71,9 @@ suite('Editor Commands - Trim Trailing Whitespace Command', () => {
|
||||
'even more text ',
|
||||
'and some mixed\t \t'
|
||||
], [pos(1,11), pos(3,2), pos(5,1), pos(4,1), pos(5,10)], [
|
||||
TU.createInsertDeleteSingleEditOp(null, 3, 2, 3, 4),
|
||||
TU.createInsertDeleteSingleEditOp(null, 4, 15, 4, 17),
|
||||
TU.createInsertDeleteSingleEditOp(null, 5, 15, 5, 20)
|
||||
createInsertDeleteSingleEditOp(null, 3, 2, 3, 4),
|
||||
createInsertDeleteSingleEditOp(null, 4, 15, 4, 17),
|
||||
createInsertDeleteSingleEditOp(null, 5, 15, 5, 20)
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
|
||||
|
||||
suite('Editor Config - CommonEditorConfig', () => {
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import {Cursor} from 'vs/editor/common/controller/cursor';
|
||||
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 {BracketMode} from 'vs/editor/test/common/testModes';
|
||||
import * as Modes from 'vs/editor/common/modes';
|
||||
import {Handler, EventType, IPosition, ISelection, EndOfLinePreference} from 'vs/editor/common/editorCommon';
|
||||
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
|
||||
import {EditOperation} from 'vs/editor/common/core/editOperation';
|
||||
import {EndOfLinePreference, EventType, Handler, IPosition, ISelection} from 'vs/editor/common/editorCommon';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import {IMode, IRichEditSupport, IndentAction} from 'vs/editor/common/modes';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
|
||||
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
|
||||
import {BracketMode} from 'vs/editor/test/common/testModes';
|
||||
|
||||
let H = Handler;
|
||||
|
||||
@@ -761,13 +761,13 @@ class TestMode {
|
||||
return 'testing';
|
||||
}
|
||||
|
||||
public toSimplifiedMode(): Modes.IMode {
|
||||
public toSimplifiedMode(): IMode {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class SurroundingMode extends TestMode {
|
||||
public richEditSupport: Modes.IRichEditSupport;
|
||||
public richEditSupport: IRichEditSupport;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -780,9 +780,9 @@ class SurroundingMode extends TestMode {
|
||||
}
|
||||
|
||||
class OnEnterMode extends TestMode {
|
||||
public richEditSupport: Modes.IRichEditSupport;
|
||||
public richEditSupport: IRichEditSupport;
|
||||
|
||||
constructor(indentAction: Modes.IndentAction) {
|
||||
constructor(indentAction: IndentAction) {
|
||||
super();
|
||||
this.richEditSupport = {
|
||||
onEnter: {
|
||||
@@ -886,7 +886,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
'\t}',
|
||||
'}'
|
||||
],
|
||||
mode: new OnEnterMode(Modes.IndentAction.Indent),
|
||||
mode: new OnEnterMode(IndentAction.Indent),
|
||||
config: { insertSpaces: false, tabSize: 4 }
|
||||
}, (model, cursor) => {
|
||||
moveTo(cursor, 4, 1, false);
|
||||
@@ -922,7 +922,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
text: [
|
||||
' function baz() {'
|
||||
],
|
||||
mode: new OnEnterMode(Modes.IndentAction.IndentOutdent),
|
||||
mode: new OnEnterMode(IndentAction.IndentOutdent),
|
||||
config: { insertSpaces: true, tabSize: 4 }
|
||||
}, (model, cursor) => {
|
||||
moveTo(cursor, 1, 6, false);
|
||||
@@ -1152,7 +1152,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
text: [
|
||||
'\thello'
|
||||
],
|
||||
mode: new OnEnterMode(Modes.IndentAction.Indent),
|
||||
mode: new OnEnterMode(IndentAction.Indent),
|
||||
config: { insertSpaces: true, tabSize: 4 }
|
||||
}, (model, cursor) => {
|
||||
moveTo(cursor, 1, 7, false);
|
||||
@@ -1168,7 +1168,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
text: [
|
||||
'\thello'
|
||||
],
|
||||
mode: new OnEnterMode(Modes.IndentAction.None),
|
||||
mode: new OnEnterMode(IndentAction.None),
|
||||
config: { insertSpaces: true, tabSize: 4 }
|
||||
}, (model, cursor) => {
|
||||
moveTo(cursor, 1, 7, false);
|
||||
@@ -1184,7 +1184,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
text: [
|
||||
'\thell()'
|
||||
],
|
||||
mode: new OnEnterMode(Modes.IndentAction.IndentOutdent),
|
||||
mode: new OnEnterMode(IndentAction.IndentOutdent),
|
||||
config: { insertSpaces: true, tabSize: 4 }
|
||||
}, (model, cursor) => {
|
||||
moveTo(cursor, 1, 7, false);
|
||||
@@ -1286,7 +1286,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
|
||||
interface ICursorOpts {
|
||||
text: string[];
|
||||
mode?: Modes.IMode;
|
||||
mode?: IMode;
|
||||
config?: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
import {IENarratorTextAreaState, ISimpleModel, TextAreaState} from 'vs/editor/common/controller/textAreaState';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {EndOfLinePreference, IRange, IEditorPosition} from 'vs/editor/common/editorCommon';
|
||||
import {ISimpleModel, TextAreaState, IENarratorTextAreaState} from 'vs/editor/common/controller/textAreaState';
|
||||
import {EndOfLinePreference, IEditorPosition, IRange} from 'vs/editor/common/editorCommon';
|
||||
import {MockTextAreaWrapper} from 'vs/editor/test/common/mocks/mockTextAreaWrapper';
|
||||
|
||||
suite('TextAreaState', () => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
||||
suite('Editor Core - Range', () => {
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import DiffComputer = require('vs/editor/common/diff/diffComputer');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as assert from 'assert';
|
||||
import {DiffComputer} from 'vs/editor/common/diff/diffComputer';
|
||||
import {IChange, ICharChange, ILineChange} from 'vs/editor/common/editorCommon';
|
||||
|
||||
function extractCharChangeRepresentation(change, expectedChange): EditorCommon.ICharChange {
|
||||
function extractCharChangeRepresentation(change, expectedChange): ICharChange {
|
||||
var hasOriginal = expectedChange && expectedChange.originalStartLineNumber > 0;
|
||||
var hasModified = expectedChange && expectedChange.modifiedStartLineNumber > 0;
|
||||
return {
|
||||
@@ -24,8 +24,8 @@ function extractCharChangeRepresentation(change, expectedChange): EditorCommon.I
|
||||
};
|
||||
}
|
||||
|
||||
function extractLineChangeRepresentation(change, expectedChange): EditorCommon.ILineChange {
|
||||
var result:EditorCommon.ILineChange = <any>{
|
||||
function extractLineChangeRepresentation(change, expectedChange): ILineChange {
|
||||
var result:ILineChange = <any>{
|
||||
originalStartLineNumber:change.originalStartLineNumber,
|
||||
originalEndLineNumber: change.originalEndLineNumber,
|
||||
modifiedStartLineNumber: change.modifiedStartLineNumber,
|
||||
@@ -42,8 +42,8 @@ function extractLineChangeRepresentation(change, expectedChange): EditorCommon.I
|
||||
return result;
|
||||
}
|
||||
|
||||
function assertDiff(originalLines:string[], modifiedLines:string[], expectedChanges:EditorCommon.IChange[], shouldPostProcessCharChanges:boolean = false, shouldIgnoreTrimWhitespace:boolean=false) {
|
||||
var diffComputer = new DiffComputer.DiffComputer(originalLines, modifiedLines, {
|
||||
function assertDiff(originalLines:string[], modifiedLines:string[], expectedChanges:IChange[], shouldPostProcessCharChanges:boolean = false, shouldIgnoreTrimWhitespace:boolean=false) {
|
||||
var diffComputer = new DiffComputer(originalLines, modifiedLines, {
|
||||
shouldPostProcessCharChanges: shouldPostProcessCharChanges || false,
|
||||
shouldIgnoreTrimWhitespace: shouldIgnoreTrimWhitespace || false,
|
||||
shouldConsiderTrimWhitespaceInEmptyCase: true
|
||||
@@ -57,7 +57,7 @@ function assertDiff(originalLines:string[], modifiedLines:string[], expectedChan
|
||||
assert.deepEqual(extracted, expectedChanges);
|
||||
}
|
||||
|
||||
function createLineDeletion(startLineNumber, endLineNumber, modifiedLineNumber): EditorCommon.IChange {
|
||||
function createLineDeletion(startLineNumber, endLineNumber, modifiedLineNumber): IChange {
|
||||
return {
|
||||
originalStartLineNumber: startLineNumber,
|
||||
originalEndLineNumber: endLineNumber,
|
||||
@@ -66,7 +66,7 @@ function createLineDeletion(startLineNumber, endLineNumber, modifiedLineNumber):
|
||||
};
|
||||
}
|
||||
|
||||
function createLineInsertion(startLineNumber, endLineNumber, originalLineNumber): EditorCommon.IChange {
|
||||
function createLineInsertion(startLineNumber, endLineNumber, originalLineNumber): IChange {
|
||||
return {
|
||||
originalStartLineNumber: originalLineNumber,
|
||||
originalEndLineNumber: 0,
|
||||
@@ -75,7 +75,7 @@ function createLineInsertion(startLineNumber, endLineNumber, originalLineNumber)
|
||||
};
|
||||
}
|
||||
|
||||
function createLineChange(originalStartLineNumber, originalEndLineNumber, modifiedStartLineNumber, modifiedEndLineNumber, charChanges): EditorCommon.ILineChange {
|
||||
function createLineChange(originalStartLineNumber, originalEndLineNumber, modifiedStartLineNumber, modifiedEndLineNumber, charChanges): ILineChange {
|
||||
return {
|
||||
originalStartLineNumber: originalStartLineNumber,
|
||||
originalEndLineNumber: originalEndLineNumber,
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import Model = require('vs/editor/common/model/model');
|
||||
import {IPosition} from 'vs/editor/common/editorCommon';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
|
||||
export function pos(lineNumber:number, column:number): EditorCommon.IPosition {
|
||||
export function pos(lineNumber:number, column:number): IPosition {
|
||||
return {
|
||||
lineNumber: lineNumber,
|
||||
column: column
|
||||
};
|
||||
}
|
||||
|
||||
export function withEditorModel(text:string[], callback:(model:Model.Model) => void): void {
|
||||
var model = new Model.Model(text.join('\n'), null);
|
||||
export function withEditorModel(text:string[], callback:(model:Model) => void): void {
|
||||
var model = new Model(text.join('\n'), null);
|
||||
callback(model);
|
||||
model.dispose();
|
||||
}
|
||||
|
||||
@@ -4,33 +4,33 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {CommonCodeEditor} from 'vs/editor/common/commonCodeEditor';
|
||||
import {Cursor} from 'vs/editor/common/controller/cursor';
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import {EventEmitter, IEventEmitter} from 'vs/base/common/eventEmitter';
|
||||
import {CommonEditorConfiguration, IIndentationGuesser} from 'vs/editor/common/config/commonEditorConfig';
|
||||
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
|
||||
import {MockKeybindingService} from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import {MockCodeEditorService} from 'vs/editor/test/common/mocks/mockCodeEditorService';
|
||||
import {MockTelemetryService} from 'vs/platform/telemetry/test/common/mockTelemetryService';
|
||||
import * as InstantiationService from 'vs/platform/instantiation/common/instantiationService';
|
||||
import {createInstantiationService} from 'vs/platform/instantiation/common/instantiationService';
|
||||
import {IKeybindingScopeLocation} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {MockKeybindingService} from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import {MockTelemetryService} from 'vs/platform/telemetry/test/common/mockTelemetryService';
|
||||
import {CommonCodeEditor} from 'vs/editor/common/commonCodeEditor';
|
||||
import {CommonEditorConfiguration, IIndentationGuesser} from 'vs/editor/common/config/commonEditorConfig';
|
||||
import {Cursor} from 'vs/editor/common/controller/cursor';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import {MockCodeEditorService} from 'vs/editor/test/common/mocks/mockCodeEditorService';
|
||||
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
|
||||
|
||||
export class MockCodeEditor extends CommonCodeEditor {
|
||||
protected _createConfiguration(options:EditorCommon.ICodeEditorWidgetCreationOptions, indentationGuesser:IIndentationGuesser): CommonEditorConfiguration {
|
||||
protected _createConfiguration(options:editorCommon.ICodeEditorWidgetCreationOptions, indentationGuesser:IIndentationGuesser): CommonEditorConfiguration {
|
||||
return new MockConfiguration(options);
|
||||
}
|
||||
public getCenteredRangeInViewport(): EditorCommon.IEditorRange { return null; }
|
||||
public getCenteredRangeInViewport(): editorCommon.IEditorRange { return null; }
|
||||
public setScrollTop(newScrollTop:number): void { }
|
||||
public getScrollTop(): number { return 0; }
|
||||
public setScrollLeft(newScrollLeft:number): void { }
|
||||
public getScrollLeft(): number { return 0; }
|
||||
public getScrollWidth(): number { return 0; }
|
||||
public getScrollHeight(): number { return 0; }
|
||||
public saveViewState(): EditorCommon.ICodeEditorViewState { return null; }
|
||||
public restoreViewState(state:EditorCommon.IEditorViewState): void { }
|
||||
public layout(dimension?:EditorCommon.IDimension): void { }
|
||||
public saveViewState(): editorCommon.ICodeEditorViewState { return null; }
|
||||
public restoreViewState(state:editorCommon.IEditorViewState): void { }
|
||||
public layout(dimension?:editorCommon.IDimension): void { }
|
||||
public focus(): void { }
|
||||
public isFocused(): boolean { return true; }
|
||||
protected _enableEmptySelectionClipboard(): boolean { return false; }
|
||||
@@ -42,7 +42,7 @@ export class MockCodeEditor extends CommonCodeEditor {
|
||||
return this.cursor;
|
||||
}
|
||||
|
||||
public registerAndInstantiateContribution<T extends EditorCommon.IEditorContribution>(ctor:any): T {
|
||||
public registerAndInstantiateContribution<T extends editorCommon.IEditorContribution>(ctor:any): T {
|
||||
let r = <T>this._instantiationService.createInstance(ctor, this);
|
||||
this.contributions[r.getId()] = r;
|
||||
return r;
|
||||
@@ -54,13 +54,13 @@ export class MockScopeLocation implements IKeybindingScopeLocation {
|
||||
removeAttribute(attr:string): void { }
|
||||
}
|
||||
|
||||
export function withMockCodeEditor(text:string[], options:EditorCommon.ICodeEditorWidgetCreationOptions, callback:(editor:MockCodeEditor, cursor:Cursor)=>void): void {
|
||||
export function withMockCodeEditor(text:string[], options:editorCommon.ICodeEditorWidgetCreationOptions, callback:(editor:MockCodeEditor, cursor:Cursor)=>void): void {
|
||||
|
||||
let codeEditorService = new MockCodeEditorService();
|
||||
let keybindingService = new MockKeybindingService();
|
||||
let telemetryService = new MockTelemetryService();
|
||||
|
||||
let instantiationService = InstantiationService.createInstantiationService({
|
||||
let instantiationService = createInstantiationService({
|
||||
codeEditorService: codeEditorService,
|
||||
keybindingService: keybindingService,
|
||||
telemetryService: telemetryService
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {ITextAreaWrapper, IClipboardEvent, IKeyboardEventWrapper} from 'vs/editor/common/controller/textAreaState';
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
import {Disposable} from 'vs/base/common/lifecycle';
|
||||
import {IClipboardEvent, IKeyboardEventWrapper, ITextAreaWrapper} from 'vs/editor/common/controller/textAreaState';
|
||||
|
||||
export class MockTextAreaWrapper extends Disposable implements ITextAreaWrapper {
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import {EndOfLinePreference, EndOfLineSequence, EventType, IIdentifiedSingleEditOperation, IModelContentChangedEvent2} from 'vs/editor/common/editorCommon';
|
||||
import {EditableTextModel, IValidatedEditOperation} from 'vs/editor/common/model/editableTextModel';
|
||||
import {TextModel} from 'vs/editor/common/model/textModel';
|
||||
import {MirrorModel2} from 'vs/editor/common/model/mirrorModel2';
|
||||
import {TextModel} from 'vs/editor/common/model/textModel';
|
||||
import {assertSyncedModels, testApplyEditsWithSyncedModels} from 'vs/editor/test/common/model/editableTextModelTestUtils';
|
||||
|
||||
suite('EditorModel - EditableTextModel._getInverseEdits', () => {
|
||||
@@ -274,7 +274,7 @@ suite('EditorModel - EditableTextModel._toSingleEditOperation', () => {
|
||||
|
||||
function testSimpleApplyEdits(original:string[], edits:IValidatedEditOperation[], expected:IValidatedEditOperation): void {
|
||||
let model = new EditableTextModel([], TextModel.toRawText(original.join('\n')), null);
|
||||
model.setEOL(EditorCommon.EndOfLineSequence.LF);
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
|
||||
let actual = model._toSingleEditOperation(edits);
|
||||
assert.deepEqual(actual, expected);
|
||||
@@ -514,7 +514,7 @@ suite('EditorModel - EditableTextModel._toSingleEditOperation', () => {
|
||||
|
||||
suite('EditorModel - EditableTextModel.applyEdits', () => {
|
||||
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text:string[]): EditorCommon.IIdentifiedSingleEditOperation {
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text:string[]): IIdentifiedSingleEditOperation {
|
||||
return {
|
||||
identifier: null,
|
||||
range: new Range(startLineNumber, startColumn, endLineNumber, endColumn),
|
||||
@@ -1211,7 +1211,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
||||
|
||||
}, (model) => {
|
||||
var isFirstTime = true;
|
||||
model.addListener(EditorCommon.EventType.ModelContentChanged2, (e:EditorCommon.IModelContentChangedEvent2) => {
|
||||
model.addListener(EventType.ModelContentChanged2, (e:IModelContentChangedEvent2) => {
|
||||
if (!isFirstTime) {
|
||||
return;
|
||||
}
|
||||
@@ -1234,7 +1234,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
||||
let mirrorModel2 = new MirrorModel2(null, model.toRawText().lines, model.toRawText().EOL, model.getVersionId());
|
||||
let mirrorModel2PrevVersionId = model.getVersionId();
|
||||
|
||||
model.addListener(EditorCommon.EventType.ModelContentChanged2, (e:EditorCommon.IModelContentChangedEvent2) => {
|
||||
model.addListener(EventType.ModelContentChanged2, (e:IModelContentChangedEvent2) => {
|
||||
let versionId = e.versionId;
|
||||
if (versionId < mirrorModel2PrevVersionId) {
|
||||
console.warn('Model version id did not advance between edits (2)');
|
||||
@@ -1249,7 +1249,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
||||
assert.equal(mirrorModel2.version, model.getVersionId(), 'mirror model 2 version OK');
|
||||
};
|
||||
|
||||
model.setEOL(EditorCommon.EndOfLineSequence.CRLF);
|
||||
model.setEOL(EndOfLineSequence.CRLF);
|
||||
assertMirrorModels();
|
||||
|
||||
model.dispose();
|
||||
@@ -1266,7 +1266,7 @@ interface ILightWeightMarker {
|
||||
|
||||
suite('EditorModel - EditableTextModel.applyEdits & markers', () => {
|
||||
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text:string[]): EditorCommon.IIdentifiedSingleEditOperation {
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text:string[]): IIdentifiedSingleEditOperation {
|
||||
return {
|
||||
identifier: null,
|
||||
range: new Range(startLineNumber, startColumn, endLineNumber, endColumn),
|
||||
@@ -1292,7 +1292,7 @@ suite('EditorModel - EditableTextModel.applyEdits & markers', () => {
|
||||
return result;
|
||||
}
|
||||
|
||||
function testApplyEditsAndMarkers(text:string[], markers:ILightWeightMarker[], edits:EditorCommon.IIdentifiedSingleEditOperation[], changedMarkers:string[], expectedText:string[], expectedMarkers:ILightWeightMarker[]): void {
|
||||
function testApplyEditsAndMarkers(text:string[], markers:ILightWeightMarker[], edits:IIdentifiedSingleEditOperation[], changedMarkers:string[], expectedText:string[], expectedMarkers:ILightWeightMarker[]): void {
|
||||
var textStr = text.join('\n');
|
||||
var expectedTextStr = expectedText.join('\n');
|
||||
var markersMap = toMarkersMap(markers);
|
||||
@@ -1300,7 +1300,7 @@ suite('EditorModel - EditableTextModel.applyEdits & markers', () => {
|
||||
var markerId2ModelMarkerId = Object.create(null);
|
||||
|
||||
var model = new EditableTextModel([], TextModel.toRawText(textStr), null);
|
||||
model.setEOL(EditorCommon.EndOfLineSequence.LF);
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
|
||||
// Add markers
|
||||
markers.forEach((m) => {
|
||||
@@ -1313,7 +1313,7 @@ suite('EditorModel - EditableTextModel.applyEdits & markers', () => {
|
||||
model._assertLineNumbersOK();
|
||||
|
||||
// Assert edits produced expected result
|
||||
assert.deepEqual(model.getValue(EditorCommon.EndOfLinePreference.LF), expectedTextStr);
|
||||
assert.deepEqual(model.getValue(EndOfLinePreference.LF), expectedTextStr);
|
||||
|
||||
let actualChangedMarkers: string[] = [];
|
||||
for (let i = 0, len = expectedMarkers.length; i < len; i++) {
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import Position = require('vs/editor/common/core/position');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import {IIdentifiedSingleEditOperation} from 'vs/editor/common/editorCommon';
|
||||
import {testApplyEditsWithSyncedModels} from 'vs/editor/test/common/model/editableTextModelTestUtils';
|
||||
|
||||
const GENERATE_TESTS = false;
|
||||
|
||||
suite('EditorModel Auto Tests', () => {
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text:string[]): EditorCommon.IIdentifiedSingleEditOperation {
|
||||
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text:string[]): IIdentifiedSingleEditOperation {
|
||||
return {
|
||||
identifier: null,
|
||||
range: new Range(startLineNumber, startColumn, endLineNumber, endColumn),
|
||||
@@ -164,7 +164,7 @@ class TestModel {
|
||||
|
||||
public initialContent: string;
|
||||
public resultingContent: string;
|
||||
public edits: EditorCommon.IIdentifiedSingleEditOperation[];
|
||||
public edits: IIdentifiedSingleEditOperation[];
|
||||
|
||||
constructor() {
|
||||
this.initialContent = generateFile(false);
|
||||
@@ -174,14 +174,14 @@ class TestModel {
|
||||
let lineNumber = 1;
|
||||
let column = 1;
|
||||
|
||||
let editStartPosition: Position.Position = null;
|
||||
let editStartPosition: Position = null;
|
||||
this.edits = [];
|
||||
for (let offset = 0, len = this.initialContent.length; currentEditIdx < edits.length && offset <= len; offset++) {
|
||||
let ch = this.initialContent.charAt(offset);
|
||||
|
||||
if (!editStartPosition) {
|
||||
if (offset === edits[currentEditIdx].offset) {
|
||||
editStartPosition = new Position.Position(lineNumber, column);
|
||||
editStartPosition = new Position(lineNumber, column);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as assert from 'assert';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {EditableTextModel} from 'vs/editor/common/model/editableTextModel';
|
||||
import {TextModel} from 'vs/editor/common/model/textModel';
|
||||
import {IMirrorModelEvents, MirrorModel} from 'vs/editor/common/model/mirrorModel';
|
||||
import {MirrorModel2} from 'vs/editor/common/model/mirrorModel2';
|
||||
import {MirrorModel, IMirrorModelEvents} from 'vs/editor/common/model/mirrorModel';
|
||||
import {TextModel} from 'vs/editor/common/model/textModel';
|
||||
|
||||
export function testApplyEditsWithSyncedModels(original:string[], edits:EditorCommon.IIdentifiedSingleEditOperation[], expected:string[]): void {
|
||||
export function testApplyEditsWithSyncedModels(original:string[], edits:editorCommon.IIdentifiedSingleEditOperation[], expected:string[]): void {
|
||||
var originalStr = original.join('\n');
|
||||
var expectedStr = expected.join('\n');
|
||||
|
||||
@@ -20,7 +20,7 @@ export function testApplyEditsWithSyncedModels(original:string[], edits:EditorCo
|
||||
var inverseEdits = model.applyEdits(edits);
|
||||
|
||||
// Assert edits produced expected result
|
||||
assert.deepEqual(model.getValue(EditorCommon.EndOfLinePreference.LF), expectedStr);
|
||||
assert.deepEqual(model.getValue(editorCommon.EndOfLinePreference.LF), expectedStr);
|
||||
|
||||
assertMirrorModels();
|
||||
|
||||
@@ -28,7 +28,7 @@ export function testApplyEditsWithSyncedModels(original:string[], edits:EditorCo
|
||||
var inverseInverseEdits = model.applyEdits(inverseEdits);
|
||||
|
||||
// Assert the inverse edits brought back model to original state
|
||||
assert.deepEqual(model.getValue(EditorCommon.EndOfLinePreference.LF), originalStr);
|
||||
assert.deepEqual(model.getValue(editorCommon.EndOfLinePreference.LF), originalStr);
|
||||
|
||||
// Assert the inverse of the inverse edits are the original edits
|
||||
assert.deepEqual(inverseInverseEdits, edits);
|
||||
@@ -39,7 +39,7 @@ export function testApplyEditsWithSyncedModels(original:string[], edits:EditorCo
|
||||
|
||||
export function assertSyncedModels(text:string, callback:(model:EditableTextModel, assertMirrorModels:()=>void)=>void, setup:(model:EditableTextModel)=>void = null): void {
|
||||
var model = new EditableTextModel([], TextModel.toRawText(text), null);
|
||||
model.setEOL(EditorCommon.EndOfLineSequence.LF);
|
||||
model.setEOL(editorCommon.EndOfLineSequence.LF);
|
||||
|
||||
if (setup) {
|
||||
setup(model);
|
||||
@@ -51,7 +51,7 @@ export function assertSyncedModels(text:string, callback:(model:EditableTextMod
|
||||
var mirrorModel2 = new MirrorModel2(null, model.toRawText().lines, model.toRawText().EOL, model.getVersionId());
|
||||
var mirrorModel2PrevVersionId = model.getVersionId();
|
||||
|
||||
model.addListener(EditorCommon.EventType.ModelContentChanged, (e:EditorCommon.IModelContentChangedEvent) => {
|
||||
model.addListener(editorCommon.EventType.ModelContentChanged, (e:editorCommon.IModelContentChangedEvent) => {
|
||||
let versionId = e.versionId;
|
||||
if (versionId < mirrorModel1PrevVersionId) {
|
||||
console.warn('Model version id did not advance between edits (1)');
|
||||
@@ -63,7 +63,7 @@ export function assertSyncedModels(text:string, callback:(model:EditableTextMod
|
||||
mirrorModel1.onEvents(mirrorModelEvents);
|
||||
});
|
||||
|
||||
model.addListener(EditorCommon.EventType.ModelContentChanged2, (e:EditorCommon.IModelContentChangedEvent2) => {
|
||||
model.addListener(editorCommon.EventType.ModelContentChanged2, (e:editorCommon.IModelContentChangedEvent2) => {
|
||||
let versionId = e.versionId;
|
||||
if (versionId < mirrorModel2PrevVersionId) {
|
||||
console.warn('Model version id did not advance between edits (2)');
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import assert = require('assert');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import MirrorModel = require('vs/editor/common/model/mirrorModel');
|
||||
import modesUtil = require('vs/editor/test/common/modesTestUtils');
|
||||
import * as assert from 'assert';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import {IMirrorModelEvents, MirrorModel, createMirrorModelFromString} from 'vs/editor/common/model/mirrorModel';
|
||||
import {createMockMode} from 'vs/editor/test/common/modesTestUtils';
|
||||
|
||||
function equalRange(left, right) {
|
||||
if(left.startLineNumber !== right.startLineNumber) {
|
||||
@@ -21,9 +21,9 @@ function equalRange(left, right) {
|
||||
assert.ok(true, 'ranges');
|
||||
};
|
||||
|
||||
function contentChangedFlushEvent(detail: EditorCommon.IRawText): EditorCommon.IModelContentChangedFlushEvent {
|
||||
function contentChangedFlushEvent(detail: editorCommon.IRawText): editorCommon.IModelContentChangedFlushEvent {
|
||||
return {
|
||||
changeType: EditorCommon.EventType.ModelContentChangedFlush,
|
||||
changeType: editorCommon.EventType.ModelContentChangedFlush,
|
||||
isRedoing: false,
|
||||
isUndoing: false,
|
||||
versionId: 0,
|
||||
@@ -31,9 +31,9 @@ function contentChangedFlushEvent(detail: EditorCommon.IRawText): EditorCommon.I
|
||||
};
|
||||
}
|
||||
|
||||
function contentChangedLinesDeletedEvent(fromLineNumber: number, toLineNumber: number): EditorCommon.IModelContentChangedLinesDeletedEvent {
|
||||
function contentChangedLinesDeletedEvent(fromLineNumber: number, toLineNumber: number): editorCommon.IModelContentChangedLinesDeletedEvent {
|
||||
return {
|
||||
changeType: EditorCommon.EventType.ModelContentChangedLinesDeleted,
|
||||
changeType: editorCommon.EventType.ModelContentChangedLinesDeleted,
|
||||
isRedoing: false,
|
||||
isUndoing: false,
|
||||
versionId: 0,
|
||||
@@ -42,9 +42,9 @@ function contentChangedLinesDeletedEvent(fromLineNumber: number, toLineNumber: n
|
||||
};
|
||||
}
|
||||
|
||||
function contentChangedLinesInsertedEvent(fromLineNumber: number, toLineNumber: number, detail: string): EditorCommon.IModelContentChangedLinesInsertedEvent {
|
||||
function contentChangedLinesInsertedEvent(fromLineNumber: number, toLineNumber: number, detail: string): editorCommon.IModelContentChangedLinesInsertedEvent {
|
||||
return {
|
||||
changeType: EditorCommon.EventType.ModelContentChangedLinesInserted,
|
||||
changeType: editorCommon.EventType.ModelContentChangedLinesInserted,
|
||||
isRedoing: false,
|
||||
isUndoing: false,
|
||||
versionId: 0,
|
||||
@@ -54,9 +54,9 @@ function contentChangedLinesInsertedEvent(fromLineNumber: number, toLineNumber:
|
||||
};
|
||||
}
|
||||
|
||||
function contentChangedLineChanged(lineNumber: number, detail: string): EditorCommon.IModelContentChangedLineChangedEvent {
|
||||
function contentChangedLineChanged(lineNumber: number, detail: string): editorCommon.IModelContentChangedLineChangedEvent {
|
||||
return {
|
||||
changeType: EditorCommon.EventType.ModelContentChangedLineChanged,
|
||||
changeType: editorCommon.EventType.ModelContentChangedLineChanged,
|
||||
isRedoing: false,
|
||||
isUndoing: false,
|
||||
versionId: 0,
|
||||
@@ -65,7 +65,7 @@ function contentChangedLineChanged(lineNumber: number, detail: string): EditorCo
|
||||
};
|
||||
}
|
||||
|
||||
function mirrorModelEvents(contentChanged:EditorCommon.IModelContentChangedEvent[]): MirrorModel.IMirrorModelEvents {
|
||||
function mirrorModelEvents(contentChanged:editorCommon.IModelContentChangedEvent[]): IMirrorModelEvents {
|
||||
return {
|
||||
contentChanged: contentChanged
|
||||
};
|
||||
@@ -73,10 +73,10 @@ function mirrorModelEvents(contentChanged:EditorCommon.IModelContentChangedEvent
|
||||
|
||||
suite('Editor Model - MirrorModel', () => {
|
||||
|
||||
var mirrorModel:MirrorModel.MirrorModel;
|
||||
var mirrorModel:MirrorModel;
|
||||
|
||||
setup(() => {
|
||||
mirrorModel = MirrorModel.createMirrorModelFromString(null, 0, 'line1\nline2\nline3\nline4', modesUtil.createMockMode('mock.mode.id'));
|
||||
mirrorModel = createMirrorModelFromString(null, 0, 'line1\nline2\nline3\nline4', createMockMode('mock.mode.id'));
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -125,7 +125,7 @@ suite('Editor Model - MirrorModel', () => {
|
||||
});
|
||||
|
||||
test('get (all/unique) words', () => {
|
||||
var model = MirrorModel.createMirrorModelFromString(null, 0, 'foo bar foo bar', modesUtil.createMockMode('mock.mode.id'));
|
||||
var model = createMirrorModelFromString(null, 0, 'foo bar foo bar', createMockMode('mock.mode.id'));
|
||||
var words = model.getAllWords();
|
||||
var uniqueWords = model.getAllUniqueWords();
|
||||
assert.equal(words.length, 4);
|
||||
@@ -137,7 +137,7 @@ suite('Editor Model - MirrorModel', () => {
|
||||
assert.equal(uniqueWords[0], 'foo');
|
||||
assert.equal(uniqueWords[1], 'bar');
|
||||
|
||||
model = MirrorModel.createMirrorModelFromString(null, 0, 'foo bar\nfoo\nbar', modesUtil.createMockMode('mock.mode.id'));
|
||||
model = createMirrorModelFromString(null, 0, 'foo bar\nfoo\nbar', createMockMode('mock.mode.id'));
|
||||
words = model.getAllWords();
|
||||
uniqueWords = model.getAllUniqueWords();
|
||||
assert.equal(words.length, 4);
|
||||
@@ -154,7 +154,7 @@ suite('Editor Model - MirrorModel', () => {
|
||||
var pos = { lineNumber: 1, column: 3 };
|
||||
assert.equal(mirrorModel.getWordAtPosition(pos).word, 'line1');
|
||||
|
||||
var model = MirrorModel.createMirrorModelFromString(null, 0, 'foo bar 1234 :";\'', modesUtil.createMockMode('mock.mode.id'));
|
||||
var model = createMirrorModelFromString(null, 0, 'foo bar 1234 :";\'', createMockMode('mock.mode.id'));
|
||||
assert.equal(model.getWordAtPosition({lineNumber: 1, column: 1}).word, 'foo');
|
||||
assert.equal(model.getWordAtPosition({lineNumber: 1, column: 2}).word, 'foo');
|
||||
assert.equal(model.getWordAtPosition({lineNumber: 1, column: 3}).word, 'foo');
|
||||
@@ -189,7 +189,7 @@ suite('Editor Model - MirrorModel', () => {
|
||||
assert.equal(wordsWithRanges[3].text, 'line4');
|
||||
equalRange(wordsWithRanges[3].range, { startLineNumber: 4, startColumn: 1, endLineNumber: 4, endColumn: 6 });
|
||||
|
||||
var model = MirrorModel.createMirrorModelFromString(null, 0, 'foo bar\nfoo\nbar', modesUtil.createMockMode('mock.mode.id'));
|
||||
var model = createMirrorModelFromString(null, 0, 'foo bar\nfoo\nbar', createMockMode('mock.mode.id'));
|
||||
wordsWithRanges = model.getAllWordsWithRange();
|
||||
assert.equal(wordsWithRanges.length, 4);
|
||||
assert.equal(wordsWithRanges[0].text, 'foo');
|
||||
@@ -205,10 +205,10 @@ suite('Editor Model - MirrorModel', () => {
|
||||
|
||||
suite('Editor Model - MirrorModel Eventing', () => {
|
||||
|
||||
var mirrorModel:MirrorModel.MirrorModel;
|
||||
var mirrorModel:MirrorModel;
|
||||
|
||||
setup(() => {
|
||||
mirrorModel = MirrorModel.createMirrorModelFromString(null, 0, 'line one\nline two\nline three\nline four', modesUtil.createMockMode('mock.mode.id'));
|
||||
mirrorModel = createMirrorModelFromString(null, 0, 'line one\nline two\nline three\nline four', createMockMode('mock.mode.id'));
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {IFoundBracket} from 'vs/editor/common/editorCommon';
|
||||
import {TextModel} from 'vs/editor/common/model/textModel';
|
||||
import {TextModelWithTokens} from 'vs/editor/common/model/textModelWithTokens';
|
||||
import {IFoundBracket} from 'vs/editor/common/editorCommon';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
||||
suite('TextModelWithTokens', () => {
|
||||
|
||||
|
||||
@@ -4,27 +4,27 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import ModelLine = require('vs/editor/common/model/modelLine');
|
||||
import * as Modes from 'vs/editor/common/modes';
|
||||
import TextModelWithTokens = require('vs/editor/common/model/textModelWithTokens');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as assert from 'assert';
|
||||
import {ILineTokens, LineTokensBinaryEncoding} from 'vs/editor/common/editorCommon';
|
||||
import * as modelLine from 'vs/editor/common/model/modelLine';
|
||||
import {LineMarker} from 'vs/editor/common/model/textModelWithMarkers';
|
||||
import {TokensInflatorMap} from 'vs/editor/common/model/textModelWithTokens';
|
||||
import {IToken} from 'vs/editor/common/modes';
|
||||
|
||||
function assertLineTokens(actual:EditorCommon.ILineTokens, expected:Modes.IToken[]): void {
|
||||
var inflatedActual = EditorCommon.LineTokensBinaryEncoding.inflateArr(actual.getBinaryEncodedTokensMap(), actual.getBinaryEncodedTokens());
|
||||
function assertLineTokens(actual:ILineTokens, expected:IToken[]): void {
|
||||
var inflatedActual = LineTokensBinaryEncoding.inflateArr(actual.getBinaryEncodedTokensMap(), actual.getBinaryEncodedTokens());
|
||||
assert.deepEqual(inflatedActual, expected, 'Line tokens are equal');
|
||||
}
|
||||
|
||||
suite('Editor Model - ModelLine.applyEdits text', () => {
|
||||
suite('Editor Model - modelLine.applyEdits text', () => {
|
||||
|
||||
function testEdits(initial:string, edits:ModelLine.ILineEdit[], expected:string): void {
|
||||
var line = new ModelLine.ModelLine(1, initial);
|
||||
function testEdits(initial:string, edits:modelLine.ILineEdit[], expected:string): void {
|
||||
var line = new modelLine.ModelLine(1, initial);
|
||||
line.applyEdits({}, edits);
|
||||
assert.equal(line.text, expected);
|
||||
}
|
||||
|
||||
function editOp(startColumn: number, endColumn: number, text:string): ModelLine.ILineEdit {
|
||||
function editOp(startColumn: number, endColumn: number, text:string): modelLine.ILineEdit {
|
||||
return {
|
||||
startColumn: startColumn,
|
||||
endColumn: endColumn,
|
||||
@@ -163,10 +163,10 @@ suite('Editor Model - ModelLine.applyEdits text', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Model - ModelLine.split text', () => {
|
||||
suite('Editor Model - modelLine.split text', () => {
|
||||
|
||||
function testLineSplit(initial:string, splitColumn:number, expected1:string, expected2:string): void {
|
||||
var line = new ModelLine.ModelLine(1, initial);
|
||||
var line = new modelLine.ModelLine(1, initial);
|
||||
var newLine = line.split({}, splitColumn, false);
|
||||
assert.equal(line.text, expected1);
|
||||
assert.equal(newLine.text, expected2);
|
||||
@@ -200,11 +200,11 @@ suite('Editor Model - ModelLine.split text', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Model - ModelLine.append text', () => {
|
||||
suite('Editor Model - modelLine.append text', () => {
|
||||
|
||||
function testLineAppend(a:string, b:string, expected:string): void {
|
||||
var line1 = new ModelLine.ModelLine(1, a);
|
||||
var line2 = new ModelLine.ModelLine(2, b);
|
||||
var line1 = new modelLine.ModelLine(1, a);
|
||||
var line2 = new modelLine.ModelLine(2, b);
|
||||
line1.append({}, line2);
|
||||
assert.equal(line1.text, expected);
|
||||
}
|
||||
@@ -234,10 +234,10 @@ suite('Editor Model - ModelLine.append text', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Model - ModelLine.applyEdits text & tokens', () => {
|
||||
function testLineEditTokens(initialText:string, initialTokens: Modes.IToken[], edits:ModelLine.ILineEdit[], expectedText:string, expectedTokens: Modes.IToken[]): void {
|
||||
var line = new ModelLine.ModelLine(1, initialText);
|
||||
line.setTokens(new TextModelWithTokens.TokensInflatorMap(), initialTokens, null, []);
|
||||
suite('Editor Model - modelLine.applyEdits text & tokens', () => {
|
||||
function testLineEditTokens(initialText:string, initialTokens: IToken[], edits:modelLine.ILineEdit[], expectedText:string, expectedTokens: IToken[]): void {
|
||||
var line = new modelLine.ModelLine(1, initialText);
|
||||
line.setTokens(new TokensInflatorMap(), initialTokens, null, []);
|
||||
|
||||
line.applyEdits({}, edits);
|
||||
|
||||
@@ -246,8 +246,8 @@ suite('Editor Model - ModelLine.applyEdits text & tokens', () => {
|
||||
}
|
||||
|
||||
test('insertion on empty line', () => {
|
||||
var line = new ModelLine.ModelLine(1, 'some text');
|
||||
var map = new TextModelWithTokens.TokensInflatorMap();
|
||||
var line = new modelLine.ModelLine(1, 'some text');
|
||||
var map = new TokensInflatorMap();
|
||||
line.setTokens(map, [{startIndex: 0, type:'bar'}], null, []);
|
||||
|
||||
line.applyEdits({}, [{startColumn:1, endColumn:10, text:'', forceMoveMarkers: false}]);
|
||||
@@ -808,10 +808,10 @@ suite('Editor Model - ModelLine.applyEdits text & tokens', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Model - ModelLine.split text & tokens', () => {
|
||||
function testLineSplitTokens(initialText:string, initialTokens: Modes.IToken[], splitColumn:number, expectedText1:string, expectedText2:string, expectedTokens: Modes.IToken[]): void {
|
||||
var line = new ModelLine.ModelLine(1, initialText);
|
||||
line.setTokens(new TextModelWithTokens.TokensInflatorMap(), initialTokens, null, []);
|
||||
suite('Editor Model - modelLine.split text & tokens', () => {
|
||||
function testLineSplitTokens(initialText:string, initialTokens: IToken[], splitColumn:number, expectedText1:string, expectedText2:string, expectedTokens: IToken[]): void {
|
||||
var line = new modelLine.ModelLine(1, initialText);
|
||||
line.setTokens(new TokensInflatorMap(), initialTokens, null, []);
|
||||
|
||||
var other = line.split({}, splitColumn, false);
|
||||
|
||||
@@ -890,14 +890,14 @@ suite('Editor Model - ModelLine.split text & tokens', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Model - ModelLine.append text & tokens', () => {
|
||||
function testLineAppendTokens(aText:string, aTokens: Modes.IToken[], bText:string, bTokens:Modes.IToken[], expectedText:string, expectedTokens:Modes.IToken[]): void {
|
||||
var inflator = new TextModelWithTokens.TokensInflatorMap();
|
||||
suite('Editor Model - modelLine.append text & tokens', () => {
|
||||
function testLineAppendTokens(aText:string, aTokens: IToken[], bText:string, bTokens:IToken[], expectedText:string, expectedTokens:IToken[]): void {
|
||||
var inflator = new TokensInflatorMap();
|
||||
|
||||
var a = new ModelLine.ModelLine(1, aText);
|
||||
var a = new modelLine.ModelLine(1, aText);
|
||||
a.setTokens(inflator, aTokens, null, []);
|
||||
|
||||
var b = new ModelLine.ModelLine(2, bText);
|
||||
var b = new modelLine.ModelLine(2, bText);
|
||||
b.setTokens(inflator, bTokens, null, []);
|
||||
|
||||
a.append({}, b);
|
||||
@@ -1017,13 +1017,13 @@ interface ILightWeightMarker {
|
||||
stickToPreviousCharacter: boolean;
|
||||
}
|
||||
|
||||
suite('Editor Model - ModelLine.applyEdits text & markers', () => {
|
||||
suite('Editor Model - modelLine.applyEdits text & markers', () => {
|
||||
|
||||
function marker(id: number, column: number, stickToPreviousCharacter: boolean): LineMarker {
|
||||
return new LineMarker(String(id), column, stickToPreviousCharacter);
|
||||
}
|
||||
|
||||
function toLightWeightMarker(marker:ModelLine.ILineMarker): ILightWeightMarker {
|
||||
function toLightWeightMarker(marker:modelLine.ILineMarker): ILightWeightMarker {
|
||||
return {
|
||||
id: marker.id,
|
||||
column: marker.column,
|
||||
@@ -1031,8 +1031,8 @@ suite('Editor Model - ModelLine.applyEdits text & markers', () => {
|
||||
};
|
||||
}
|
||||
|
||||
function testLineEditMarkers(initialText:string, initialMarkers: LineMarker[], edits:ModelLine.ILineEdit[], expectedText:string, expectedChangedMarkers:number[], _expectedMarkers: LineMarker[]): void {
|
||||
var line = new ModelLine.ModelLine(1, initialText);
|
||||
function testLineEditMarkers(initialText:string, initialMarkers: LineMarker[], edits:modelLine.ILineEdit[], expectedText:string, expectedChangedMarkers:number[], _expectedMarkers: LineMarker[]): void {
|
||||
var line = new modelLine.ModelLine(1, initialText);
|
||||
line.addMarkers(initialMarkers);
|
||||
|
||||
var changedMarkers = Object.create(null);
|
||||
@@ -1833,13 +1833,13 @@ suite('Editor Model - ModelLine.applyEdits text & markers', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Model - ModelLine.split text & markers', () => {
|
||||
suite('Editor Model - modelLine.split text & markers', () => {
|
||||
|
||||
function marker(id: number, column: number, stickToPreviousCharacter: boolean): LineMarker {
|
||||
return new LineMarker(String(id), column, stickToPreviousCharacter);
|
||||
}
|
||||
|
||||
function toLightWeightMarker(marker:ModelLine.ILineMarker): ILightWeightMarker {
|
||||
function toLightWeightMarker(marker:modelLine.ILineMarker): ILightWeightMarker {
|
||||
return {
|
||||
id: marker.id,
|
||||
column: marker.column,
|
||||
@@ -1848,7 +1848,7 @@ suite('Editor Model - ModelLine.split text & markers', () => {
|
||||
}
|
||||
|
||||
function testLineSplitMarkers(initialText:string, initialMarkers: LineMarker[], splitColumn:number, forceMoveMarkers:boolean, expectedText1:string, expectedText2:string, expectedChangedMarkers:number[], _expectedMarkers1: LineMarker[], _expectedMarkers2: LineMarker[]): void {
|
||||
var line = new ModelLine.ModelLine(1, initialText);
|
||||
var line = new modelLine.ModelLine(1, initialText);
|
||||
line.addMarkers(initialMarkers);
|
||||
|
||||
var changedMarkers = Object.create(null);
|
||||
@@ -2101,13 +2101,13 @@ suite('Editor Model - ModelLine.split text & markers', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Model - ModelLine.append text & markers', () => {
|
||||
suite('Editor Model - modelLine.append text & markers', () => {
|
||||
|
||||
function marker(id: number, column: number, stickToPreviousCharacter: boolean): LineMarker {
|
||||
return new LineMarker(String(id), column, stickToPreviousCharacter);
|
||||
}
|
||||
|
||||
function toLightWeightMarker(marker:ModelLine.ILineMarker): ILightWeightMarker {
|
||||
function toLightWeightMarker(marker:modelLine.ILineMarker): ILightWeightMarker {
|
||||
return {
|
||||
id: marker.id,
|
||||
column: marker.column,
|
||||
@@ -2116,10 +2116,10 @@ suite('Editor Model - ModelLine.append text & markers', () => {
|
||||
}
|
||||
|
||||
function testLinePrependMarkers(aText:string, aMarkers: LineMarker[], bText:string, bMarkers: LineMarker[], expectedText:string, expectedChangedMarkers:number[], _expectedMarkers: LineMarker[]): void {
|
||||
var a = new ModelLine.ModelLine(1, aText);
|
||||
var a = new modelLine.ModelLine(1, aText);
|
||||
a.addMarkers(aMarkers);
|
||||
|
||||
var b = new ModelLine.ModelLine(1, bText);
|
||||
var b = new modelLine.ModelLine(1, bText);
|
||||
b.addMarkers(bMarkers);
|
||||
|
||||
var changedMarkers = Object.create(null);
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
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 Model = require('vs/editor/common/model/model');
|
||||
import ModelModes = require('vs/editor/test/common/testModes');
|
||||
import {EditOperation} from 'vs/editor/common/core/editOperation';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import {ModelMode1, ModelMode2, NMode} from 'vs/editor/test/common/testModes';
|
||||
|
||||
// --------- utils
|
||||
|
||||
@@ -32,7 +32,7 @@ function stateEqual(state, content) {
|
||||
assert.equal(state.prevLineContent, content);
|
||||
}
|
||||
|
||||
function statesEqual(model:Model.Model, states:string[]) {
|
||||
function statesEqual(model:Model, states:string[]) {
|
||||
var i, len = states.length - 1;
|
||||
for (i = 0; i < len; i++) {
|
||||
stateEqual(model._lines[i].getState(), states[i]);
|
||||
@@ -50,18 +50,18 @@ var LINE5 = '5';
|
||||
|
||||
suite('Editor Model - Model Modes 1', () => {
|
||||
|
||||
var thisHighlighter: ModelModes.ModelMode1;
|
||||
var thisModel: Model.Model;
|
||||
var thisHighlighter: ModelMode1;
|
||||
var thisModel: Model;
|
||||
|
||||
setup(() => {
|
||||
thisHighlighter = new ModelModes.ModelMode1();
|
||||
thisHighlighter = new ModelMode1();
|
||||
var text =
|
||||
LINE1 + '\r\n' +
|
||||
LINE2 + '\n' +
|
||||
LINE3 + '\n' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
thisModel = new Model.Model(text, thisHighlighter);
|
||||
thisModel = new Model(text, thisHighlighter);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -168,18 +168,18 @@ suite('Editor Model - Model Modes 1', () => {
|
||||
|
||||
suite('Editor Model - Model Modes 2', () => {
|
||||
|
||||
var thisHighlighter: ModelModes.ModelMode1;
|
||||
var thisModel: Model.Model;
|
||||
var thisHighlighter: ModelMode1;
|
||||
var thisModel: Model;
|
||||
|
||||
setup(() => {
|
||||
thisHighlighter = new ModelModes.ModelMode2();
|
||||
thisHighlighter = new ModelMode2();
|
||||
var text =
|
||||
'Line1' + '\r\n' +
|
||||
'Line2' + '\n' +
|
||||
'Line3' + '\n' +
|
||||
'Line4' + '\r\n' +
|
||||
'Line5';
|
||||
thisModel = new Model.Model(text, thisHighlighter);
|
||||
thisModel = new Model(text, thisHighlighter);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -251,15 +251,15 @@ suite('Editor Model - Model Modes 2', () => {
|
||||
|
||||
suite('Editor Model - Token Iterator', () => {
|
||||
|
||||
var thisModel: Model.Model;
|
||||
var thisModel: Model;
|
||||
|
||||
setup(() => {
|
||||
var nmode = new ModelModes.NMode(3);
|
||||
var nmode = new NMode(3);
|
||||
var text =
|
||||
'foobarfoobar' + '\r\n' +
|
||||
'foobarfoobar' + '\r\n' +
|
||||
'foobarfoobar' + '\r\n';
|
||||
thisModel = new Model.Model(text, nmode);
|
||||
thisModel = new Model(text, nmode);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import Model = require('vs/editor/common/model/model');
|
||||
import * as assert from 'assert';
|
||||
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 ModelModes = require('vs/editor/test/common/testModes');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import {EditOperation} from 'vs/editor/common/core/editOperation';
|
||||
import {EventType, IModelContentChangedEvent, IModelContentChangedFlushEvent} from 'vs/editor/common/editorCommon';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import {BracketMode} from 'vs/editor/test/common/testModes';
|
||||
|
||||
// --------- utils
|
||||
|
||||
@@ -46,7 +46,7 @@ var LINE5 = '1';
|
||||
|
||||
suite('Editor Model - Model', () => {
|
||||
|
||||
var thisModel: Model.Model;
|
||||
var thisModel: Model;
|
||||
|
||||
setup(() => {
|
||||
var text =
|
||||
@@ -55,7 +55,7 @@ suite('Editor Model - Model', () => {
|
||||
LINE3 + '\n' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
thisModel = new Model.Model(text, null);
|
||||
thisModel = new Model(text, null);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -115,7 +115,7 @@ suite('Editor Model - Model', () => {
|
||||
// --------- insert text eventing
|
||||
|
||||
test('model insert empty text does not trigger eventing', () => {
|
||||
thisModel.addListener(EditorCommon.EventType.ModelContentChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelContentChanged, (e) => {
|
||||
assert.ok(false, 'was not expecting event');
|
||||
});
|
||||
thisModel.applyEdits([EditOperation.insert(new Position(1, 1), '')]);
|
||||
@@ -123,9 +123,9 @@ suite('Editor Model - Model', () => {
|
||||
|
||||
test('model insert text without newline eventing', () => {
|
||||
var listenerCalls = 0;
|
||||
thisModel.addListener(EditorCommon.EventType.ModelContentChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelContentChanged, (e) => {
|
||||
listenerCalls++;
|
||||
assert.equal(e.changeType, EditorCommon.EventType.ModelContentChangedLineChanged);
|
||||
assert.equal(e.changeType, EventType.ModelContentChangedLineChanged);
|
||||
assert.equal(e.lineNumber, 1);
|
||||
});
|
||||
thisModel.applyEdits([EditOperation.insert(new Position(1, 1), 'foo ')]);
|
||||
@@ -136,10 +136,10 @@ suite('Editor Model - Model', () => {
|
||||
var listenerCalls = 0;
|
||||
var order = 0;
|
||||
|
||||
thisModel.addListener(EditorCommon.EventType.ModelContentChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelContentChanged, (e) => {
|
||||
listenerCalls++;
|
||||
|
||||
if (e.changeType === EditorCommon.EventType.ModelContentChangedLineChanged) {
|
||||
if (e.changeType === EventType.ModelContentChangedLineChanged) {
|
||||
if (order === 0) {
|
||||
assert.equal(++order, 1, 'ModelContentChangedLineChanged first');
|
||||
assert.equal(e.lineNumber, 1, 'ModelContentChangedLineChanged line number 1');
|
||||
@@ -147,7 +147,7 @@ suite('Editor Model - Model', () => {
|
||||
assert.equal(++order, 2, 'ModelContentChangedLineChanged first');
|
||||
assert.equal(e.lineNumber, 1, 'ModelContentChangedLineChanged line number 1');
|
||||
}
|
||||
} else if (e.changeType === EditorCommon.EventType.ModelContentChangedLinesInserted) {
|
||||
} else if (e.changeType === EventType.ModelContentChangedLinesInserted) {
|
||||
assert.equal(++order, 3, 'ModelContentChangedLinesInserted second');
|
||||
assert.equal(e.fromLineNumber, 2, 'ModelContentChangedLinesInserted fromLineNumber');
|
||||
assert.equal(e.toLineNumber, 2, 'ModelContentChangedLinesInserted toLineNumber');
|
||||
@@ -212,7 +212,7 @@ suite('Editor Model - Model', () => {
|
||||
// --------- delete text eventing
|
||||
|
||||
test('model delete empty text does not trigger eventing', () => {
|
||||
thisModel.addListener(EditorCommon.EventType.ModelContentChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelContentChanged, (e) => {
|
||||
assert.ok(false, 'was not expecting event');
|
||||
});
|
||||
thisModel.applyEdits([EditOperation.delete(new Range(1, 1, 1, 1))]);
|
||||
@@ -220,9 +220,9 @@ suite('Editor Model - Model', () => {
|
||||
|
||||
test('model delete text from one line eventing', () => {
|
||||
var listenerCalls = 0;
|
||||
thisModel.addListener(EditorCommon.EventType.ModelContentChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelContentChanged, (e) => {
|
||||
listenerCalls++;
|
||||
assert.equal(e.changeType, EditorCommon.EventType.ModelContentChangedLineChanged);
|
||||
assert.equal(e.changeType, EventType.ModelContentChangedLineChanged);
|
||||
assert.equal(e.lineNumber, 1);
|
||||
});
|
||||
thisModel.applyEdits([EditOperation.delete(new Range(1, 1, 1, 2))]);
|
||||
@@ -231,9 +231,9 @@ suite('Editor Model - Model', () => {
|
||||
|
||||
test('model delete all text from a line eventing', () => {
|
||||
var listenerCalls = 0;
|
||||
thisModel.addListener(EditorCommon.EventType.ModelContentChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelContentChanged, (e) => {
|
||||
listenerCalls++;
|
||||
assert.equal(e.changeType, EditorCommon.EventType.ModelContentChangedLineChanged);
|
||||
assert.equal(e.changeType, EventType.ModelContentChangedLineChanged);
|
||||
assert.equal(e.lineNumber, 1);
|
||||
});
|
||||
thisModel.applyEdits([EditOperation.delete(new Range(1, 1, 1, 14))]);
|
||||
@@ -243,10 +243,10 @@ suite('Editor Model - Model', () => {
|
||||
test('model delete text from two lines eventing', () => {
|
||||
var listenerCalls = 0;
|
||||
var order = 0;
|
||||
thisModel.addListener(EditorCommon.EventType.ModelContentChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelContentChanged, (e) => {
|
||||
listenerCalls++;
|
||||
|
||||
if (e.changeType === EditorCommon.EventType.ModelContentChangedLineChanged) {
|
||||
if (e.changeType === EventType.ModelContentChangedLineChanged) {
|
||||
if (order === 0) {
|
||||
assert.equal(++order, 1);
|
||||
assert.equal(e.lineNumber, 1);
|
||||
@@ -254,7 +254,7 @@ suite('Editor Model - Model', () => {
|
||||
assert.equal(++order, 2);
|
||||
assert.equal(e.lineNumber, 1);
|
||||
}
|
||||
} else if (e.changeType === EditorCommon.EventType.ModelContentChangedLinesDeleted) {
|
||||
} else if (e.changeType === EventType.ModelContentChangedLinesDeleted) {
|
||||
assert.equal(++order, 3);
|
||||
assert.equal(e.fromLineNumber, 2);
|
||||
assert.equal(e.toLineNumber, 2);
|
||||
@@ -271,10 +271,10 @@ suite('Editor Model - Model', () => {
|
||||
var listenerCalls = 0;
|
||||
var order = 0;
|
||||
|
||||
thisModel.addListener(EditorCommon.EventType.ModelContentChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelContentChanged, (e) => {
|
||||
listenerCalls++;
|
||||
|
||||
if (e.changeType === EditorCommon.EventType.ModelContentChangedLineChanged) {
|
||||
if (e.changeType === EventType.ModelContentChangedLineChanged) {
|
||||
if (order === 0) {
|
||||
assert.equal(++order, 1);
|
||||
assert.equal(e.lineNumber, 1);
|
||||
@@ -282,7 +282,7 @@ suite('Editor Model - Model', () => {
|
||||
assert.equal(++order, 2);
|
||||
assert.equal(e.lineNumber, 1);
|
||||
}
|
||||
} else if (e.changeType === EditorCommon.EventType.ModelContentChangedLinesDeleted) {
|
||||
} else if (e.changeType === EventType.ModelContentChangedLinesDeleted) {
|
||||
assert.equal(++order, 3);
|
||||
assert.equal(e.fromLineNumber, 2);
|
||||
assert.equal(e.toLineNumber, 3);
|
||||
@@ -330,12 +330,12 @@ suite('Editor Model - Model', () => {
|
||||
// --------- setValue
|
||||
test('setValue eventing', () => {
|
||||
var listenerCalls = 0;
|
||||
thisModel.addOneTimeListener(EditorCommon.EventType.ModelContentChanged, (e:EditorCommon.IModelContentChangedEvent) => {
|
||||
thisModel.addOneTimeListener(EventType.ModelContentChanged, (e:IModelContentChangedEvent) => {
|
||||
listenerCalls++;
|
||||
|
||||
assert.equal(e.changeType, EditorCommon.EventType.ModelContentChangedFlush);
|
||||
assert.equal(e.changeType, EventType.ModelContentChangedFlush);
|
||||
|
||||
assert.deepEqual((<EditorCommon.IModelContentChangedFlushEvent>e).detail.lines, [ 'new value' ]);
|
||||
assert.deepEqual((<IModelContentChangedFlushEvent>e).detail.lines, [ 'new value' ]);
|
||||
});
|
||||
thisModel.setValue('new value');
|
||||
assert.equal(listenerCalls, 1, 'listener calls');
|
||||
@@ -352,7 +352,7 @@ suite('Editor Model - Model', () => {
|
||||
// --------- Special Unicode LINE SEPARATOR character
|
||||
suite('Editor Model - Model Line Separators', () => {
|
||||
|
||||
var thisModel: Model.Model;
|
||||
var thisModel: Model;
|
||||
|
||||
setup(() => {
|
||||
var text =
|
||||
@@ -361,7 +361,7 @@ suite('Editor Model - Model Line Separators', () => {
|
||||
LINE3 + '\u2028' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
thisModel = new Model.Model(text, null);
|
||||
thisModel = new Model(text, null);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -377,7 +377,7 @@ suite('Editor Model - Model Line Separators', () => {
|
||||
});
|
||||
|
||||
test('Bug 13333:Model should line break on lonely CR too', () => {
|
||||
var model = new Model.Model('Hello\rWorld!\r\nAnother line', null);
|
||||
var model = new Model('Hello\rWorld!\r\nAnother line', null);
|
||||
assert.equal(model.getLineCount(), 3);
|
||||
assert.equal(model.getValue(), 'Hello\r\nWorld!\r\nAnother line');
|
||||
model.dispose();
|
||||
@@ -389,8 +389,8 @@ suite('Editor Model - Model Line Separators', () => {
|
||||
|
||||
suite('Editor Model - Bracket Matching', () => {
|
||||
|
||||
var thisModel: Model.Model;
|
||||
var bracketMode = new ModelModes.BracketMode();
|
||||
var thisModel: Model;
|
||||
var bracketMode = new BracketMode();
|
||||
|
||||
setup(() => {
|
||||
var text =
|
||||
@@ -399,7 +399,7 @@ suite('Editor Model - Bracket Matching', () => {
|
||||
'}, bar: {hallo: [{' + '\n' +
|
||||
'}, {' + '\n' +
|
||||
'}]}}';
|
||||
thisModel = new Model.Model(text, bracketMode);
|
||||
thisModel = new Model(text, bracketMode);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -457,14 +457,14 @@ suite('Editor Model - Bracket Matching', () => {
|
||||
|
||||
suite('Editor Model - Bracket Matching 2', () => {
|
||||
|
||||
var thisModel: Model.Model;
|
||||
var bracketMode = new ModelModes.BracketMode();
|
||||
var thisModel: Model;
|
||||
var bracketMode = new BracketMode();
|
||||
|
||||
setup(() => {
|
||||
var text =
|
||||
')]}{[(' + '\n' +
|
||||
')]}{[(';
|
||||
thisModel = new Model.Model(text, bracketMode);
|
||||
thisModel = new Model(text, bracketMode);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -495,11 +495,11 @@ suite('Editor Model - Bracket Matching 2', () => {
|
||||
|
||||
suite('Editor Model - Words', () => {
|
||||
|
||||
var thisModel: Model.Model;
|
||||
var thisModel: Model;
|
||||
|
||||
setup(() => {
|
||||
var text = [ 'This text has some words. ' ];
|
||||
thisModel = new Model.Model(text.join('\n'), null);
|
||||
thisModel = new Model(text.join('\n'), null);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -542,7 +542,7 @@ suite('Editor Model - Words', () => {
|
||||
// --------- Find
|
||||
suite('Editor Model - Find', () => {
|
||||
|
||||
var thisModel: Model.Model;
|
||||
var thisModel: Model;
|
||||
|
||||
setup(() => {
|
||||
var text = [
|
||||
@@ -552,7 +552,7 @@ suite('Editor Model - Find', () => {
|
||||
'It is also interesting if it\'s part of a word like amazingFooBar',
|
||||
'Again nothing interesting here'
|
||||
];
|
||||
thisModel = new Model.Model(text.join('\n'), null);
|
||||
thisModel = new Model(text.join('\n'), null);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -638,7 +638,7 @@ suite('Editor Model - Find', () => {
|
||||
'',
|
||||
'Again nothing interesting here'
|
||||
];
|
||||
var model = new Model.Model(text.join('\n'), null);
|
||||
var model = new Model(text.join('\n'), null);
|
||||
|
||||
var ranges = [
|
||||
[2, 1, 2, 1],
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as assert from 'assert';
|
||||
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 Model = require('vs/editor/common/model/model');
|
||||
import {EditOperation} from 'vs/editor/common/core/editOperation';
|
||||
import {EventType, IModelDeltaDecoration, IRange, TrackedRangeStickiness} from 'vs/editor/common/editorCommon';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
|
||||
// --------- utils
|
||||
|
||||
@@ -78,7 +78,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
|
||||
// --------- Model Decorations
|
||||
|
||||
var thisModel:Model.Model;
|
||||
var thisModel:Model;
|
||||
|
||||
setup(() => {
|
||||
var text =
|
||||
@@ -87,7 +87,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
LINE3 + '\n' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
thisModel = new Model.Model(text, null);
|
||||
thisModel = new Model(text, null);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -200,7 +200,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
|
||||
test('decorations emit event on add', () => {
|
||||
var listenerCalled = 0;
|
||||
thisModel.addListener(EditorCommon.EventType.ModelDecorationsChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelDecorationsChanged, (e) => {
|
||||
listenerCalled++;
|
||||
assert.equal(e.ids.length, 1);
|
||||
assert.equal(e.addedOrChangedDecorations.length, 1);
|
||||
@@ -219,7 +219,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
test('decorations emit event on change', () => {
|
||||
var listenerCalled = 0;
|
||||
var decId = addDecoration(thisModel, 1, 2, 3, 2, 'myType');
|
||||
thisModel.addListener(EditorCommon.EventType.ModelDecorationsChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelDecorationsChanged, (e) => {
|
||||
listenerCalled++;
|
||||
assert.equal(e.ids.length, 1);
|
||||
assert.equal(e.addedOrChangedDecorations.length, 1);
|
||||
@@ -246,7 +246,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
test('decorations emit event on remove', () => {
|
||||
var listenerCalled = 0;
|
||||
var decId = addDecoration(thisModel, 1, 2, 3, 2, 'myType');
|
||||
thisModel.addListener(EditorCommon.EventType.ModelDecorationsChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelDecorationsChanged, (e) => {
|
||||
listenerCalled++;
|
||||
assert.equal(e.ids.length, 1);
|
||||
assert.equal(e.addedOrChangedDecorations.length, 0);
|
||||
@@ -269,7 +269,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
var listenerCalled = 0;
|
||||
var decId = addDecoration(thisModel, 1, 2, 3, 2, 'myType');
|
||||
|
||||
thisModel.addListener(EditorCommon.EventType.ModelDecorationsChanged, (e) => {
|
||||
thisModel.addListener(EventType.ModelDecorationsChanged, (e) => {
|
||||
listenerCalled++;
|
||||
assert.equal(e.ids.length, 1);
|
||||
assert.equal(e.addedOrChangedDecorations.length, 1);
|
||||
@@ -398,7 +398,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
|
||||
export interface ILightWeightDecoration {
|
||||
id: string;
|
||||
range: EditorCommon.IRange;
|
||||
range: IRange;
|
||||
}
|
||||
|
||||
suite('deltaDecorations', () => {
|
||||
@@ -415,7 +415,7 @@ suite('deltaDecorations', () => {
|
||||
};
|
||||
}
|
||||
|
||||
function toModelDeltaDecoration(dec:ILightWeightDecoration): EditorCommon.IModelDeltaDecoration {
|
||||
function toModelDeltaDecoration(dec:ILightWeightDecoration): IModelDeltaDecoration {
|
||||
return {
|
||||
range: dec.range,
|
||||
options: {
|
||||
@@ -434,7 +434,7 @@ suite('deltaDecorations', () => {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function readModelDecorations(model:Model.Model, ids:string[]): ILightWeightDecoration[] {
|
||||
function readModelDecorations(model:Model, ids:string[]): ILightWeightDecoration[] {
|
||||
return ids.map((id) => {
|
||||
return {
|
||||
range: model.getDecorationRange(id),
|
||||
@@ -445,7 +445,7 @@ suite('deltaDecorations', () => {
|
||||
|
||||
function testDeltaDecorations(text:string[], decorations:ILightWeightDecoration[], newDecorations:ILightWeightDecoration[]): void {
|
||||
|
||||
var model = new Model.Model(text.join('\n'), null);
|
||||
var model = new Model(text.join('\n'), null);
|
||||
|
||||
// Add initial decorations & assert they are added
|
||||
var initialIds = model.deltaDecorations([], decorations.map(toModelDeltaDecoration));
|
||||
@@ -478,7 +478,7 @@ suite('deltaDecorations', () => {
|
||||
}
|
||||
|
||||
test('result respects input', () => {
|
||||
var model = new Model.Model([
|
||||
var model = new Model([
|
||||
'Hello world,',
|
||||
'How are you?'
|
||||
].join('\n'), null);
|
||||
@@ -565,7 +565,7 @@ suite('deltaDecorations', () => {
|
||||
});
|
||||
|
||||
test('model doesn\'t get confused with individual tracked ranges', () => {
|
||||
var model = new Model.Model([
|
||||
var model = new Model([
|
||||
'Hello world,',
|
||||
'How are you?'
|
||||
].join('\n'), null);
|
||||
@@ -575,7 +575,7 @@ suite('deltaDecorations', () => {
|
||||
startColumn: 1,
|
||||
endLineNumber: 1,
|
||||
endColumn: 1
|
||||
}, EditorCommon.TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges);
|
||||
}, TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges);
|
||||
model.removeTrackedRange(trackedRangeId);
|
||||
|
||||
var ids = model.deltaDecorations([], [
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import Range = require('vs/editor/common/core/range');
|
||||
import Model = require('vs/editor/common/model/model');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as assert from 'assert';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {IIdentifiedSingleEditOperation} from 'vs/editor/common/editorCommon';
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
|
||||
suite('Editor Model - Model Edit Operation', () => {
|
||||
var LINE1 = 'My First Line';
|
||||
@@ -16,7 +16,7 @@ suite('Editor Model - Model Edit Operation', () => {
|
||||
var LINE4 = '';
|
||||
var LINE5 = '1';
|
||||
|
||||
var model: Model.Model;
|
||||
var model: Model;
|
||||
|
||||
setup(() => {
|
||||
var text =
|
||||
@@ -25,7 +25,7 @@ suite('Editor Model - Model Edit Operation', () => {
|
||||
LINE3 + '\n' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
model = new Model.Model(text, null);
|
||||
model = new Model(text, null);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -33,8 +33,8 @@ suite('Editor Model - Model Edit Operation', () => {
|
||||
model = null;
|
||||
});
|
||||
|
||||
function createSingleEditOp(text:string, positionLineNumber:number, positionColumn:number, selectionLineNumber:number = positionLineNumber, selectionColumn:number = positionColumn):EditorCommon.IIdentifiedSingleEditOperation {
|
||||
var range = new Range.Range(
|
||||
function createSingleEditOp(text:string, positionLineNumber:number, positionColumn:number, selectionLineNumber:number = positionLineNumber, selectionColumn:number = positionColumn):IIdentifiedSingleEditOperation {
|
||||
var range = new Range(
|
||||
selectionLineNumber,
|
||||
selectionColumn,
|
||||
positionLineNumber,
|
||||
@@ -52,7 +52,7 @@ suite('Editor Model - Model Edit Operation', () => {
|
||||
};
|
||||
}
|
||||
|
||||
function assertSingleEditOp(singleEditOp:EditorCommon.IIdentifiedSingleEditOperation, editedLines:string[]) {
|
||||
function assertSingleEditOp(singleEditOp:IIdentifiedSingleEditOperation, editedLines:string[]) {
|
||||
var editOp = [singleEditOp];
|
||||
|
||||
var inverseEditOp = model.applyEdits(editOp);
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import TextModel = require('vs/editor/common/model/textModel');
|
||||
import Range = require('vs/editor/common/core/range');
|
||||
import Position = require('vs/editor/common/core/position');
|
||||
import * as assert from 'assert';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
import {TextModel} from 'vs/editor/common/model/textModel';
|
||||
|
||||
function testGuessIndentation(expectedInsertSpaces:boolean, expectedTabSize:number, text:string[], msg?:string): void {
|
||||
var m = new TextModel.TextModel([], TextModel.TextModel.toRawText(text.join('\n')));
|
||||
var m = new TextModel([], TextModel.toRawText(text.join('\n')));
|
||||
var r = m.guessIndentation(1337);
|
||||
m.dispose();
|
||||
|
||||
@@ -30,31 +30,31 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('getValueLengthInRange', () => {
|
||||
|
||||
var m = new TextModel.TextModel([], TextModel.TextModel.toRawText('My First Line\r\nMy Second Line\r\nMy Third Line'));
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 1, 1)), ''.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 1, 2)), 'M'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 1, 3)), 'y'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 1, 14)), 'My First Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 2, 1)), 'My First Line\r\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 2, 1)), 'y First Line\r\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 2, 2)), 'y First Line\r\nM'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 2, 1000)), 'y First Line\r\nMy Second Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 3, 1)), 'y First Line\r\nMy Second Line\r\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 3, 1000)), 'y First Line\r\nMy Second Line\r\nMy Third Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 1000, 1000)), 'My First Line\r\nMy Second Line\r\nMy Third Line'.length);
|
||||
var m = new TextModel([], TextModel.toRawText('My First Line\r\nMy Second Line\r\nMy Third Line'));
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 1)), ''.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 2)), 'M'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 1, 3)), 'y'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 14)), 'My First Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 2, 1)), 'My First Line\r\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 2, 1)), 'y First Line\r\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 2, 2)), 'y First Line\r\nM'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 2, 1000)), 'y First Line\r\nMy Second Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 3, 1)), 'y First Line\r\nMy Second Line\r\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 3, 1000)), 'y First Line\r\nMy Second Line\r\nMy Third Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1000, 1000)), 'My First Line\r\nMy Second Line\r\nMy Third Line'.length);
|
||||
|
||||
m = new TextModel.TextModel([], TextModel.TextModel.toRawText('My First Line\nMy Second Line\nMy Third Line'));
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 1, 1)), ''.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 1, 2)), 'M'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 1, 3)), 'y'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 1, 14)), 'My First Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 2, 1)), 'My First Line\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 2, 1)), 'y First Line\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 2, 2)), 'y First Line\nM'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 2, 1000)), 'y First Line\nMy Second Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 3, 1)), 'y First Line\nMy Second Line\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 2, 3, 1000)), 'y First Line\nMy Second Line\nMy Third Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range.Range(1, 1, 1000, 1000)), 'My First Line\nMy Second Line\nMy Third Line'.length);
|
||||
m = new TextModel([], TextModel.toRawText('My First Line\nMy Second Line\nMy Third Line'));
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 1)), ''.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 2)), 'M'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 1, 3)), 'y'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 14)), 'My First Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 2, 1)), 'My First Line\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 2, 1)), 'y First Line\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 2, 2)), 'y First Line\nM'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 2, 1000)), 'y First Line\nMy Second Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 3, 1)), 'y First Line\nMy Second Line\n'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 3, 1000)), 'y First Line\nMy Second Line\nMy Third Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1000, 1000)), 'My First Line\nMy Second Line\nMy Third Line'.length);
|
||||
});
|
||||
|
||||
test('guess indentation 1', () => {
|
||||
@@ -393,31 +393,31 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('modifyPosition', () => {
|
||||
|
||||
var m = new TextModel.TextModel([], TextModel.TextModel.toRawText('line one\nline two'));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1,1), 0), new Position.Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(0,0), 0), new Position.Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(30, 1), 0), new Position.Position(2, 1));
|
||||
var m = new TextModel([], TextModel.toRawText('line one\nline two'));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1,1), 0), new Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position(0,0), 0), new Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position(30, 1), 0), new Position(2, 1));
|
||||
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1,1), 17), new Position.Position(2, 9));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1,1), 1), new Position.Position(1, 2));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1,1), 3), new Position.Position(1, 4));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1, 2), 10), new Position.Position(2, 3));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1, 5), 13), new Position.Position(2, 9));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1, 2), 16), new Position.Position(2, 9));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1,1), 17), new Position(2, 9));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1,1), 1), new Position(1, 2));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1,1), 3), new Position(1, 4));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1, 2), 10), new Position(2, 3));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1, 5), 13), new Position(2, 9));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1, 2), 16), new Position(2, 9));
|
||||
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(2, 9), -17), new Position.Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1,2), -1), new Position.Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(1,4), -3), new Position.Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(2, 3), -10), new Position.Position(1, 2));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(2, 9), -13), new Position.Position(1, 5));
|
||||
assert.deepEqual(m.modifyPosition(new Position.Position(2, 9), -16), new Position.Position(1, 2));
|
||||
assert.deepEqual(m.modifyPosition(new Position(2, 9), -17), new Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1,2), -1), new Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position(1,4), -3), new Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position(2, 3), -10), new Position(1, 2));
|
||||
assert.deepEqual(m.modifyPosition(new Position(2, 9), -13), new Position(1, 5));
|
||||
assert.deepEqual(m.modifyPosition(new Position(2, 9), -16), new Position(1, 2));
|
||||
|
||||
assert.throws(() => m.modifyPosition(new Position.Position(1, 2), 17));
|
||||
assert.throws(() => m.modifyPosition(new Position.Position(1, 2), 100));
|
||||
assert.throws(() => m.modifyPosition(new Position(1, 2), 17));
|
||||
assert.throws(() => m.modifyPosition(new Position(1, 2), 100));
|
||||
|
||||
assert.throws(() => m.modifyPosition(new Position.Position(1, 2), -2));
|
||||
assert.throws(() => m.modifyPosition(new Position.Position(1, 2), -100));
|
||||
assert.throws(() => m.modifyPosition(new Position.Position(2, 2), -100));
|
||||
assert.throws(() => m.modifyPosition(new Position.Position(2, 9), -18));
|
||||
assert.throws(() => m.modifyPosition(new Position(1, 2), -2));
|
||||
assert.throws(() => m.modifyPosition(new Position(1, 2), -100));
|
||||
assert.throws(() => m.modifyPosition(new Position(2, 2), -100));
|
||||
assert.throws(() => m.modifyPosition(new Position(2, 9), -18));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import TMState = require('vs/editor/common/modes/TMState');
|
||||
import * as assert from 'assert';
|
||||
import {TMState} from 'vs/editor/common/modes/TMState';
|
||||
|
||||
suite('Editor Modes - TMState', () => {
|
||||
test('Bug #16982: Cannot read property \'length\' of null', () => {
|
||||
var s1 = new TMState.TMState(null, null, null);
|
||||
var s2 = new TMState.TMState(null, null, null);
|
||||
var s1 = new TMState(null, null, null);
|
||||
var s2 = new TMState(null, null, null);
|
||||
assert.equal(s1.equals(s2), true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import autoIndentation = require('vs/editor/common/modes/supports/electricCharacter');
|
||||
import modesUtil = require('vs/editor/test/common/modesTestUtils');
|
||||
import * as assert from 'assert';
|
||||
import {Brackets} from 'vs/editor/common/modes/supports/electricCharacter';
|
||||
import {createLineContextFromTokenText} from 'vs/editor/test/common/modesTestUtils';
|
||||
|
||||
suite('Editor Modes - Auto Indentation', () => {
|
||||
test('Doc comments', () => {
|
||||
var brackets = new autoIndentation.Brackets('test', [],
|
||||
var brackets = new Brackets('test', [],
|
||||
{ scope: 'doc', open: '/**', lineStart: ' * ', close: ' */' });
|
||||
|
||||
assert.equal(brackets.onElectricCharacter(modesUtil.createLineContextFromTokenText([
|
||||
assert.equal(brackets.onElectricCharacter(createLineContextFromTokenText([
|
||||
{ text: '/**', type: 'doc' },
|
||||
]), 2).appendText, ' */');
|
||||
assert.equal(brackets.onElectricCharacter(modesUtil.createLineContextFromTokenText([
|
||||
assert.equal(brackets.onElectricCharacter(createLineContextFromTokenText([
|
||||
{ text: '/**', type: 'doc' },
|
||||
{ text: ' ', type: 'doc' },
|
||||
{ text: '*/', type: 'doc' },
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import assert = require('assert');
|
||||
import stream = require('vs/editor/common/modes/lineStream');
|
||||
import * as assert from 'assert';
|
||||
import {LineStream} from 'vs/editor/common/modes/lineStream';
|
||||
|
||||
suite('Editor Modes - LineStream', () => {
|
||||
|
||||
test('advanceIf - regex', () => {
|
||||
var lineStream = new stream.LineStream('...xxx...x.');
|
||||
var lineStream = new LineStream('...xxx...x.');
|
||||
assert.equal(lineStream.advanceIfRegExp(/^x/), '');
|
||||
lineStream.next();
|
||||
assert.equal(lineStream.advanceIfRegExp(/^x/), '');
|
||||
@@ -32,7 +32,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('advanceWhile - regex', () => {
|
||||
var lineStream = new stream.LineStream('...xxx...x.');
|
||||
var lineStream = new LineStream('...xxx...x.');
|
||||
assert.equal(lineStream.advanceWhile(/^x/), '');
|
||||
lineStream.next();
|
||||
assert.equal(lineStream.advanceWhile(/^x/), '');
|
||||
@@ -53,7 +53,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('advanceUntil - regex', () => {
|
||||
var lineStream = new stream.LineStream('...x..xx..x');
|
||||
var lineStream = new LineStream('...x..xx..x');
|
||||
assert.equal(lineStream.advanceUntil(/^x/, false), '...');
|
||||
assert.equal(lineStream.advanceUntil(/^x/, false), '');
|
||||
lineStream.next();
|
||||
@@ -69,7 +69,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('advanceUntil - regex (including)', () => {
|
||||
var lineStream = new stream.LineStream('...x..xx..x');
|
||||
var lineStream = new LineStream('...x..xx..x');
|
||||
assert.equal(lineStream.advanceUntil(/^x/, true), '...x');
|
||||
assert.equal(lineStream.advanceUntil(/^x/, true), '..x');
|
||||
assert.equal(lineStream.advanceUntil(/^x/, true), 'x');
|
||||
@@ -78,7 +78,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('advanceIf - string', () => {
|
||||
var lineStream = new stream.LineStream('...abcabcabc...abc.');
|
||||
var lineStream = new LineStream('...abcabcabc...abc.');
|
||||
assert.equal(lineStream.advanceIfString('abc'), '');
|
||||
lineStream.next();
|
||||
assert.equal(lineStream.advanceIfString('abc'), '');
|
||||
@@ -101,7 +101,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('advanceWhile - string', () => {
|
||||
var lineStream = new stream.LineStream('...abcabcabc...abc.');
|
||||
var lineStream = new LineStream('...abcabcabc...abc.');
|
||||
assert.equal(lineStream.advanceWhile('abc'), '');
|
||||
lineStream.next();
|
||||
assert.equal(lineStream.advanceWhile('abc'), '');
|
||||
@@ -122,7 +122,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('advanceUntil - string', () => {
|
||||
var lineStream = new stream.LineStream('...abc..ab..abc..bc');
|
||||
var lineStream = new LineStream('...abc..ab..abc..bc');
|
||||
assert.equal(lineStream.advanceUntil('abc', false), '...');
|
||||
assert.equal(lineStream.advanceUntil('abc', false), '');
|
||||
lineStream.next();
|
||||
@@ -134,7 +134,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('advanceUntil - string (including)', () => {
|
||||
var lineStream = new stream.LineStream('...abc..ab..abc..bc');
|
||||
var lineStream = new LineStream('...abc..ab..abc..bc');
|
||||
assert.equal(lineStream.advanceUntil('abc', true), '...abc');
|
||||
assert.equal(lineStream.advanceUntil('abc', true), '..ab..abc');
|
||||
assert.equal(lineStream.advanceUntil('abc', true), '..bc');
|
||||
@@ -142,7 +142,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('skipWhitespace', () => {
|
||||
var lineStream = new stream.LineStream('\ta bc d \t e ');
|
||||
var lineStream = new LineStream('\ta bc d \t e ');
|
||||
assert.equal(lineStream.skipWhitespace(), '\t');
|
||||
lineStream.next();
|
||||
assert.equal(lineStream.skipWhitespace(), ' ');
|
||||
@@ -157,7 +157,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('peekToken', () => {
|
||||
var lineStream = new stream.LineStream('a b c edf ');
|
||||
var lineStream = new LineStream('a b c edf ');
|
||||
assert.equal(lineStream.peekToken(), 'a');
|
||||
lineStream.next();
|
||||
assert.equal(lineStream.peekToken(), 'b');
|
||||
@@ -182,7 +182,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('nextToken', () => {
|
||||
var lineStream = new stream.LineStream('a b c edf ');
|
||||
var lineStream = new LineStream('a b c edf ');
|
||||
assert.equal(lineStream.nextToken(), 'a');
|
||||
assert.equal(lineStream.nextToken(), 'b');
|
||||
assert.equal(lineStream.nextToken(), 'c');
|
||||
@@ -193,7 +193,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
function newTokenStream(source, separators, whitespace) {
|
||||
var lineStream = new stream.LineStream(source);
|
||||
var lineStream = new LineStream(source);
|
||||
lineStream.setTokenRules(separators, whitespace);
|
||||
return lineStream;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ suite('Editor Modes - LineStream', () => {
|
||||
});
|
||||
|
||||
test('next & goBack', () => {
|
||||
var lineStream = new stream.LineStream('albert, bart, charlie, damon, erich');
|
||||
var lineStream = new LineStream('albert, bart, charlie, damon, erich');
|
||||
lineStream.setTokenRules(',', ' ');
|
||||
|
||||
assert.equal(lineStream.peekToken(), 'albert');
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import LinkComputer = require('vs/editor/common/modes/linkComputer');
|
||||
import * as Modes from 'vs/editor/common/modes';
|
||||
import * as assert from 'assert';
|
||||
import {ILink} from 'vs/editor/common/modes';
|
||||
import {ILinkComputerTarget, computeLinks} from 'vs/editor/common/modes/linkComputer';
|
||||
|
||||
class SimpleLinkComputerTarget implements LinkComputer.ILinkComputerTarget {
|
||||
class SimpleLinkComputerTarget implements ILinkComputerTarget {
|
||||
|
||||
constructor(private _lines:string[]) {
|
||||
// Intentional Empty
|
||||
@@ -23,9 +23,9 @@ class SimpleLinkComputerTarget implements LinkComputer.ILinkComputerTarget {
|
||||
}
|
||||
}
|
||||
|
||||
function computeLinks(lines:string[]): Modes.ILink[] {
|
||||
function myComputeLinks(lines:string[]): ILink[] {
|
||||
var target = new SimpleLinkComputerTarget(lines);
|
||||
return LinkComputer.computeLinks(target);
|
||||
return computeLinks(target);
|
||||
}
|
||||
|
||||
function assertLink(text:string, extractedLink:string): void {
|
||||
@@ -50,7 +50,7 @@ function assertLink(text:string, extractedLink:string): void {
|
||||
}
|
||||
}
|
||||
|
||||
var r = computeLinks([text]);
|
||||
var r = myComputeLinks([text]);
|
||||
assert.deepEqual(r, [{
|
||||
range: {
|
||||
startLineNumber: 1,
|
||||
@@ -65,7 +65,7 @@ function assertLink(text:string, extractedLink:string): void {
|
||||
suite('Editor Modes - Link Computer', () => {
|
||||
|
||||
test('Null model',() => {
|
||||
var r = LinkComputer.computeLinks(null);
|
||||
var r = computeLinks(null);
|
||||
assert.deepEqual(r, []);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import 'vs/languages/plaintext/common/plaintext.contribution';
|
||||
import 'vs/languages/html/common/html.contribution';
|
||||
|
||||
import assert = require('assert');
|
||||
import 'vs/languages/plaintext/common/plaintext.contribution';
|
||||
import * as assert from 'assert';
|
||||
import {createMockModeService} from 'vs/editor/test/common/servicesTestUtils';
|
||||
|
||||
suite('Editor Modes - Modes Registry', () => {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import {IBracketPair, OnEnterSupport} from 'vs/editor/common/modes/supports/onEnter';
|
||||
import * as assert from 'assert';
|
||||
import {IndentAction} from 'vs/editor/common/modes';
|
||||
import {IBracketPair, OnEnterSupport} from 'vs/editor/common/modes/supports/onEnter';
|
||||
|
||||
suite('OnEnter', () => {
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import {tokenizeToHtmlContent} from 'vs/editor/common/modes/textToHtmlTokenizer';
|
||||
import * as assert from 'assert';
|
||||
import {IMode, IStream, ITokenizationResult, ITokenizationSupport} from 'vs/editor/common/modes';
|
||||
import {AbstractState} from 'vs/editor/common/modes/abstractState';
|
||||
import modes = require('vs/editor/common/modes');
|
||||
import {TokenizationSupport} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
import {tokenizeToHtmlContent} from 'vs/editor/common/modes/textToHtmlTokenizer';
|
||||
|
||||
suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
test('TextToHtmlTokenizer', () => {
|
||||
@@ -58,7 +58,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
|
||||
class State extends AbstractState {
|
||||
|
||||
constructor(mode:modes.IMode) {
|
||||
constructor(mode:IMode) {
|
||||
super(mode);
|
||||
}
|
||||
|
||||
@@ -66,14 +66,14 @@ class State extends AbstractState {
|
||||
return new State(this.getMode());
|
||||
}
|
||||
|
||||
public tokenize(stream:modes.IStream):modes.ITokenizationResult {
|
||||
public tokenize(stream:IStream):ITokenizationResult {
|
||||
return { type: stream.next() === '.' ? '' : 'text' };
|
||||
}
|
||||
}
|
||||
|
||||
class Mode implements modes.IMode {
|
||||
class Mode implements IMode {
|
||||
|
||||
public tokenizationSupport: modes.ITokenizationSupport;
|
||||
public tokenizationSupport: ITokenizationSupport;
|
||||
|
||||
constructor() {
|
||||
this.tokenizationSupport = new TokenizationSupport(this, {
|
||||
@@ -85,7 +85,7 @@ class Mode implements modes.IMode {
|
||||
return 'testMode';
|
||||
}
|
||||
|
||||
public toSimplifiedMode(): modes.IMode {
|
||||
public toSimplifiedMode(): IMode {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import modes = require('vs/editor/common/modes');
|
||||
import supports = require('vs/editor/common/modes/supports');
|
||||
import {AbstractState} from 'vs/editor/common/modes/abstractState';
|
||||
import {createLineContext} from 'vs/editor/test/common/modesTestUtils';
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as assert from 'assert';
|
||||
import {IDisposable, empty as EmptyDisposable} from 'vs/base/common/lifecycle';
|
||||
import {TokenizationSupport, IEnteringNestedModeData, ILeavingNestedModeData} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
import {IModeSupportChangedEvent} from 'vs/editor/common/editorCommon';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import {AbstractState} from 'vs/editor/common/modes/abstractState';
|
||||
import {handleEvent} from 'vs/editor/common/modes/supports';
|
||||
import {IEnteringNestedModeData, ILeavingNestedModeData, TokenizationSupport} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
import {createLineContext} from 'vs/editor/test/common/modesTestUtils';
|
||||
|
||||
export class State extends AbstractState {
|
||||
|
||||
@@ -119,7 +119,7 @@ export class SwitchingMode implements modes.IMode {
|
||||
return this;
|
||||
}
|
||||
|
||||
public addSupportChangedListener(callback: (e: EditorCommon.IModeSupportChangedEvent) => void): IDisposable {
|
||||
public addSupportChangedListener(callback: (e: IModeSupportChangedEvent) => void): IDisposable {
|
||||
return EmptyDisposable;
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ suite('Editor Modes - Tokenization', () => {
|
||||
{ startIndex: 5, id: 'B' }
|
||||
]);
|
||||
|
||||
supports.handleEvent(createLineContext('abc (def', lineTokens), 0, (mode:modes.IMode, context:modes.ILineContext, offset:number) => {
|
||||
handleEvent(createLineContext('abc (def', lineTokens), 0, (mode:modes.IMode, context:modes.ILineContext, offset:number) => {
|
||||
assert.deepEqual(mode.getId(), 'A');
|
||||
assert.equal(context.getTokenCount(), 3);
|
||||
assert.equal(context.getTokenStartIndex(0), 0);
|
||||
@@ -368,7 +368,7 @@ suite('Editor Modes - Tokenization', () => {
|
||||
assert.equal(context.getLineContent(), 'abc (');
|
||||
});
|
||||
|
||||
supports.handleEvent(createLineContext('abc (def', lineTokens), 6, (mode:modes.IMode, context:modes.ILineContext, offset:number) => {
|
||||
handleEvent(createLineContext('abc (def', lineTokens), 6, (mode:modes.IMode, context:modes.ILineContext, offset:number) => {
|
||||
assert.deepEqual(mode.getId(), 'B');
|
||||
assert.equal(context.getTokenCount(), 1);
|
||||
assert.equal(context.getTokenStartIndex(0), 0);
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as Modes from 'vs/editor/common/modes';
|
||||
import {Arrays} from 'vs/editor/common/core/arrays';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
|
||||
|
||||
class SimpleTokenTypeClassificationMode implements Modes.IMode {
|
||||
class SimpleTokenTypeClassificationMode implements modes.IMode {
|
||||
|
||||
private _id:string;
|
||||
|
||||
public richEditSupport: Modes.IRichEditSupport;
|
||||
public richEditSupport: modes.IRichEditSupport;
|
||||
|
||||
constructor(id:string, wordRegExp:RegExp) {
|
||||
this._id = id;
|
||||
@@ -25,24 +25,24 @@ class SimpleTokenTypeClassificationMode implements Modes.IMode {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public toSimplifiedMode(): Modes.IMode {
|
||||
public toSimplifiedMode(): modes.IMode {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
export function createMockMode(id:string, wordRegExp:RegExp = null):Modes.IMode {
|
||||
export function createMockMode(id:string, wordRegExp:RegExp = null):modes.IMode {
|
||||
return new SimpleTokenTypeClassificationMode(id, wordRegExp);
|
||||
}
|
||||
|
||||
export interface TokenText {
|
||||
text: string;
|
||||
type: string;
|
||||
bracket?: Modes.Bracket;
|
||||
bracket?: modes.Bracket;
|
||||
}
|
||||
|
||||
export function createLineContextFromTokenText(tokens: TokenText[]): Modes.ILineContext {
|
||||
export function createLineContextFromTokenText(tokens: TokenText[]): modes.ILineContext {
|
||||
var line = '';
|
||||
var processedTokens: Modes.IToken[] = [];
|
||||
var processedTokens: modes.IToken[] = [];
|
||||
|
||||
var indexSoFar = 0;
|
||||
for (var i = 0; i < tokens.length; ++i){
|
||||
@@ -54,17 +54,17 @@ export function createLineContextFromTokenText(tokens: TokenText[]): Modes.ILine
|
||||
return new TestLineContext(line, processedTokens, null);
|
||||
}
|
||||
|
||||
export function createLineContext(line:string, tokens:Modes.ILineTokens): Modes.ILineContext {
|
||||
export function createLineContext(line:string, tokens:modes.ILineTokens): modes.ILineContext {
|
||||
return new TestLineContext(line, tokens.tokens, tokens.modeTransitions);
|
||||
}
|
||||
|
||||
class TestLineContext implements Modes.ILineContext {
|
||||
class TestLineContext implements modes.ILineContext {
|
||||
|
||||
public modeTransitions: Modes.IModeTransition[];
|
||||
public modeTransitions: modes.IModeTransition[];
|
||||
private _line:string;
|
||||
private _tokens: Modes.IToken[];
|
||||
private _tokens: modes.IToken[];
|
||||
|
||||
constructor(line:string, tokens: Modes.IToken[], modeTransitions:Modes.IModeTransition[]) {
|
||||
constructor(line:string, tokens: modes.IToken[], modeTransitions:modes.IModeTransition[]) {
|
||||
this.modeTransitions = modeTransitions;
|
||||
this._line = line;
|
||||
this._tokens = tokens;
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import servicesUtil = require('vs/editor/test/common/servicesTestUtils');
|
||||
import modes = require('vs/editor/common/modes');
|
||||
import monarchTypes = require('vs/editor/common/modes/monarch/monarchTypes');
|
||||
import monarchCompile = require('vs/editor/common/modes/monarch/monarchCompile');
|
||||
import monarchLexer = require('vs/editor/common/modes/monarch/monarchLexer');
|
||||
import {Model} from 'vs/editor/common/model/model';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import {compile} from 'vs/editor/common/modes/monarch/monarchCompile';
|
||||
import {createTokenizationSupport} from 'vs/editor/common/modes/monarch/monarchLexer';
|
||||
import {ILanguage} from 'vs/editor/common/modes/monarch/monarchTypes';
|
||||
import {createMockModeService} from 'vs/editor/test/common/servicesTestUtils';
|
||||
|
||||
export interface IRelaxedToken {
|
||||
startIndex:number;
|
||||
@@ -31,7 +31,7 @@ export function assertWords(actual:string[], expected:string[], message?:string)
|
||||
export function load(modeId: string, preloadModes: string[] = [] ): TPromise<modes.IMode> {
|
||||
var toLoad:string[] = [].concat(preloadModes).concat([modeId]);
|
||||
|
||||
var modeService = servicesUtil.createMockModeService();
|
||||
var modeService = createMockModeService();
|
||||
|
||||
var promises = toLoad.map(modeId => modeService.getOrCreateMode(modeId));
|
||||
|
||||
@@ -115,12 +115,12 @@ export function executeTests(tokenizationSupport: modes.ITokenizationSupport, te
|
||||
}
|
||||
|
||||
|
||||
export function executeMonarchTokenizationTests(name:string, language:monarchTypes.ILanguage, tests:ITestItem[][]): void {
|
||||
var lexer = monarchCompile.compile(language);
|
||||
export function executeMonarchTokenizationTests(name:string, language:ILanguage, tests:ITestItem[][]): void {
|
||||
var lexer = compile(language);
|
||||
|
||||
var modeService = servicesUtil.createMockModeService();
|
||||
var modeService = createMockModeService();
|
||||
|
||||
var tokenizationSupport = monarchLexer.createTokenizationSupport(modeService, new SimpleMode('mock.mode'), lexer);
|
||||
var tokenizationSupport = createTokenizationSupport(modeService, new SimpleMode('mock.mode'), lexer);
|
||||
|
||||
executeTests(tokenizationSupport, tests);
|
||||
}
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import Service = require('vs/editor/common/services/resourceServiceImpl');
|
||||
import MirrorModel = require('vs/editor/common/model/mirrorModel');
|
||||
import resourceService = require('vs/editor/common/services/resourceService');
|
||||
import {createMirrorModelFromString} from 'vs/editor/common/model/mirrorModel';
|
||||
import {ResourceEvents} from 'vs/editor/common/services/resourceService';
|
||||
import {ResourceService} from 'vs/editor/common/services/resourceServiceImpl';
|
||||
|
||||
suite('Editor Services - ResourceService', () => {
|
||||
|
||||
test('insert, remove, all', () => {
|
||||
|
||||
var service = new Service.ResourceService();
|
||||
var service = new ResourceService();
|
||||
|
||||
service.insert(URI.parse('test://1'), MirrorModel.createMirrorModelFromString(null, 1, 'hi', null));
|
||||
service.insert(URI.parse('test://1'), createMirrorModelFromString(null, 1, 'hi', null));
|
||||
assert.equal(service.all().length, 1);
|
||||
|
||||
service.insert(URI.parse('test://2'), MirrorModel.createMirrorModelFromString(null, 1, 'hi', null));
|
||||
service.insert(URI.parse('test://2'), createMirrorModelFromString(null, 1, 'hi', null));
|
||||
assert.equal(service.all().length, 2);
|
||||
|
||||
assert.ok(service.contains(URI.parse('test://1')));
|
||||
@@ -37,13 +37,13 @@ suite('Editor Services - ResourceService', () => {
|
||||
var eventCnt = 0;
|
||||
|
||||
var url = URI.parse('far');
|
||||
var element = MirrorModel.createMirrorModelFromString(null, 1, 'hi', null);
|
||||
var service = new Service.ResourceService();
|
||||
service.addListener(resourceService.ResourceEvents.ADDED, () => {
|
||||
var element = createMirrorModelFromString(null, 1, 'hi', null);
|
||||
var service = new ResourceService();
|
||||
service.addListener(ResourceEvents.ADDED, () => {
|
||||
eventCnt++;
|
||||
assert.ok(true);
|
||||
});
|
||||
service.addListener(resourceService.ResourceEvents.REMOVED, () => {
|
||||
service.addListener(ResourceEvents.REMOVED, () => {
|
||||
eventCnt++;
|
||||
assert.ok(true);
|
||||
});
|
||||
@@ -58,10 +58,10 @@ suite('Editor Services - ResourceService', () => {
|
||||
var eventCnt = 0;
|
||||
|
||||
var url = URI.parse('far');
|
||||
var element = MirrorModel.createMirrorModelFromString(null, 1, 'hi', null);
|
||||
var element = createMirrorModelFromString(null, 1, 'hi', null);
|
||||
var event = {};
|
||||
|
||||
var service = new Service.ResourceService();
|
||||
var service = new ResourceService();
|
||||
service.insert(url, element);
|
||||
|
||||
service.addBulkListener((events) => {
|
||||
|
||||
@@ -4,35 +4,33 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {IResourceService} from 'vs/editor/common/services/resourceService';
|
||||
import {IModelService} from 'vs/editor/common/services/modelService';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {ModeServiceImpl} from 'vs/editor/common/services/modeServiceImpl';
|
||||
import {ModelServiceImpl} from 'vs/editor/common/services/modelServiceImpl';
|
||||
import {NULL_THREAD_SERVICE} from 'vs/platform/test/common/nullThreadService';
|
||||
import {AbstractPluginService, ActivatedPlugin} from 'vs/platform/plugins/common/abstractPluginService';
|
||||
import * as InstantiationService from 'vs/platform/instantiation/common/instantiationService';
|
||||
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import {IContextViewService, IContextMenuService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IContextMenuService, IContextViewService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {IFileService} from 'vs/platform/files/common/files';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {createInstantiationService} from 'vs/platform/instantiation/common/instantiationService';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import {IMarkerService} from 'vs/platform/markers/common/markers';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {AbstractPluginService, ActivatedPlugin} from 'vs/platform/plugins/common/abstractPluginService';
|
||||
import {IPluginService} from 'vs/platform/plugins/common/plugins';
|
||||
import {IProgressService} from 'vs/platform/progress/common/progress';
|
||||
import {IStorageService} from 'vs/platform/storage/common/storage';
|
||||
import {IRequestService} from 'vs/platform/request/common/request';
|
||||
import {ISearchService} from 'vs/platform/search/common/search';
|
||||
import {IStorageService} from 'vs/platform/storage/common/storage';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {NULL_THREAD_SERVICE} from 'vs/platform/test/common/nullThreadService';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IPluginService} from 'vs/platform/plugins/common/plugins';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {ModeServiceImpl} from 'vs/editor/common/services/modeServiceImpl';
|
||||
import {IModelService} from 'vs/editor/common/services/modelService';
|
||||
import {ModelServiceImpl} from 'vs/editor/common/services/modelServiceImpl';
|
||||
import {IResourceService} from 'vs/editor/common/services/resourceService';
|
||||
|
||||
export interface IMockPlatformServices {
|
||||
threadService?:IThreadService;
|
||||
@@ -56,7 +54,7 @@ export interface IMockPlatformServices {
|
||||
fileService?:IFileService;
|
||||
}
|
||||
|
||||
export function createMockPlatformServices(mockPlatformServices:IMockPlatformServices = {}): any {
|
||||
function createMockPlatformServices(mockPlatformServices:IMockPlatformServices = {}): any {
|
||||
return {
|
||||
threadService: mockPlatformServices.threadService,
|
||||
pluginService: mockPlatformServices.pluginService,
|
||||
@@ -85,13 +83,6 @@ export interface IMockEditorServices extends IMockPlatformServices {
|
||||
modeService?: IModeService;
|
||||
}
|
||||
|
||||
export function createMockEditorServices(mockEditorServices: IMockEditorServices = {}):any {
|
||||
var ret = createMockPlatformServices(mockEditorServices);
|
||||
ret['modelService'] = mockEditorServices.modelService;
|
||||
ret['modeService'] = mockEditorServices.modeService;
|
||||
return ret;
|
||||
}
|
||||
|
||||
export interface IMockEditorWorkerServices extends IMockPlatformServices {
|
||||
resourceService?: IResourceService;
|
||||
}
|
||||
@@ -144,7 +135,7 @@ export function createMockModeService(): IModeService {
|
||||
var threadService = NULL_THREAD_SERVICE;
|
||||
var pluginService = new MockPluginService();
|
||||
var modeService = new MockModeService(threadService, pluginService);
|
||||
var inst = InstantiationService.createInstantiationService({
|
||||
var inst = createInstantiationService({
|
||||
threadService: threadService,
|
||||
pluginService: pluginService,
|
||||
modeService: modeService
|
||||
@@ -158,7 +149,7 @@ export function createMockModelService(): IModelService {
|
||||
var pluginService = new MockPluginService();
|
||||
var modeService = new MockModeService(threadService, pluginService);
|
||||
var modelService = new MockModelService(threadService, null, modeService);
|
||||
var inst = InstantiationService.createInstantiationService({
|
||||
var inst = createInstantiationService({
|
||||
threadService: threadService,
|
||||
pluginService: pluginService,
|
||||
modeService: modeService
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import modes = require('vs/editor/common/modes');
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import {AbstractState} from 'vs/editor/common/modes/abstractState';
|
||||
import {RichEditSupport} from 'vs/editor/common/modes/supports/richEditSupport';
|
||||
import {TokenizationSupport} from 'vs/editor/common/modes/supports/tokenizationSupport';
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import EditorLayoutProvider = require('vs/editor/common/viewLayout/editorLayoutProvider');
|
||||
import * as assert from 'assert';
|
||||
import {IEditorLayoutInfo} from 'vs/editor/common/editorCommon';
|
||||
import {EditorLayoutProvider, IEditorLayoutProviderOpts} from 'vs/editor/common/viewLayout/editorLayoutProvider';
|
||||
|
||||
suite('Editor ViewLayout - EditorLayoutProvider', () => {
|
||||
|
||||
function doTest(input:EditorLayoutProvider.IEditorLayoutProviderOpts, expected:IEditorLayoutInfo): void {
|
||||
let actual = EditorLayoutProvider.EditorLayoutProvider.compute(input);
|
||||
function doTest(input:IEditorLayoutProviderOpts, expected:IEditorLayoutInfo): void {
|
||||
let actual = EditorLayoutProvider.compute(input);
|
||||
assert.deepEqual(actual, expected);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import EditorScrollable = require('vs/editor/common/viewLayout/editorScrollable');
|
||||
import * as assert from 'assert';
|
||||
import {EditorScrollable} from 'vs/editor/common/viewLayout/editorScrollable';
|
||||
|
||||
suite('Editor ViewLayout - EditorScrollable', () => {
|
||||
|
||||
function assertScrollState(scrollable:EditorScrollable.EditorScrollable, scrollTop:number, scrollLeft:number, width:number, height:number, scrollWidth:number, scrollHeight:number) {
|
||||
function assertScrollState(scrollable:EditorScrollable, scrollTop:number, scrollLeft:number, width:number, height:number, scrollWidth:number, scrollHeight:number) {
|
||||
assert.equal(scrollable.getScrollTop(), scrollTop);
|
||||
assert.equal(scrollable.getScrollLeft(), scrollLeft);
|
||||
assert.equal(scrollable.getScrollWidth(), scrollWidth);
|
||||
@@ -19,7 +19,7 @@ suite('Editor ViewLayout - EditorScrollable', () => {
|
||||
}
|
||||
|
||||
test('EditorScrollable', () => {
|
||||
var scrollable = new EditorScrollable.EditorScrollable();
|
||||
var scrollable = new EditorScrollable();
|
||||
|
||||
scrollable.setWidth(100);
|
||||
scrollable.setHeight(100);
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import VerticalObjects = require('vs/editor/common/viewLayout/verticalObjects');
|
||||
import * as assert from 'assert';
|
||||
import {VerticalObjects} from 'vs/editor/common/viewLayout/verticalObjects';
|
||||
|
||||
suite('Editor ViewLayout - VerticalObjects', () => {
|
||||
|
||||
test('VerticalObjects 1', () => {
|
||||
|
||||
var verticalObjects = new VerticalObjects.VerticalObjects();
|
||||
var verticalObjects = new VerticalObjects();
|
||||
|
||||
// Start off with 10 lines
|
||||
verticalObjects.replaceLines(10);
|
||||
@@ -122,7 +122,7 @@ suite('Editor ViewLayout - VerticalObjects', () => {
|
||||
|
||||
test('VerticalObjects 2', () => {
|
||||
|
||||
var verticalObjects = new VerticalObjects.VerticalObjects();
|
||||
var verticalObjects = new VerticalObjects();
|
||||
|
||||
// Start off with 10 lines and one whitespace after line 2, of height 5
|
||||
verticalObjects.replaceLines(10);
|
||||
@@ -221,7 +221,7 @@ suite('Editor ViewLayout - VerticalObjects', () => {
|
||||
});
|
||||
|
||||
test('VerticalObjects getLineNumberAtOrAfterVerticalOffset', () => {
|
||||
var verticalObjects = new VerticalObjects.VerticalObjects();
|
||||
var verticalObjects = new VerticalObjects();
|
||||
verticalObjects.replaceLines(10);
|
||||
verticalObjects.insertWhitespace(6, 0, 10);
|
||||
|
||||
@@ -271,7 +271,7 @@ suite('Editor ViewLayout - VerticalObjects', () => {
|
||||
});
|
||||
|
||||
test('VerticalObjects getCenteredLineInViewport', () => {
|
||||
var verticalObjects = new VerticalObjects.VerticalObjects();
|
||||
var verticalObjects = new VerticalObjects();
|
||||
verticalObjects.replaceLines(10);
|
||||
verticalObjects.insertWhitespace(6, 0, 10);
|
||||
|
||||
@@ -355,7 +355,7 @@ suite('Editor ViewLayout - VerticalObjects', () => {
|
||||
});
|
||||
|
||||
test('VerticalObjects getLinesViewportData 1', () => {
|
||||
var verticalObjects = new VerticalObjects.VerticalObjects();
|
||||
var verticalObjects = new VerticalObjects();
|
||||
verticalObjects.replaceLines(10);
|
||||
verticalObjects.insertWhitespace(6, 0, 100);
|
||||
|
||||
@@ -476,7 +476,7 @@ suite('Editor ViewLayout - VerticalObjects', () => {
|
||||
|
||||
|
||||
test('VerticalObjects getLinesViewportData 2 & getWhitespaceViewportData', () => {
|
||||
var verticalObjects = new VerticalObjects.VerticalObjects();
|
||||
var verticalObjects = new VerticalObjects();
|
||||
verticalObjects.replaceLines(10);
|
||||
var a = verticalObjects.insertWhitespace(6, 0, 100);
|
||||
var b = verticalObjects.insertWhitespace(7, 0, 50);
|
||||
@@ -544,7 +544,7 @@ suite('Editor ViewLayout - VerticalObjects', () => {
|
||||
});
|
||||
|
||||
test('VerticalObjects getWhitespaceAtVerticalOffset', () => {
|
||||
var verticalObjects = new VerticalObjects.VerticalObjects();
|
||||
var verticalObjects = new VerticalObjects();
|
||||
verticalObjects.replaceLines(10);
|
||||
var a = verticalObjects.insertWhitespace(6, 0, 100);
|
||||
var b = verticalObjects.insertWhitespace(7, 0, 50);
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import ViewLineParts = require('vs/editor/common/viewLayout/viewLineParts');
|
||||
import * as assert from 'assert';
|
||||
import {DecorationSegment, ILineDecoration, LineDecorationsNormalizer} from 'vs/editor/common/viewLayout/viewLineParts';
|
||||
|
||||
suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
|
||||
function newDecoration(startLineNumber:number, startColumn:number, endLineNumber:number, endColumn:number, inlineClassName:string): ViewLineParts.ILineDecoration {
|
||||
function newDecoration(startLineNumber:number, startColumn:number, endLineNumber:number, endColumn:number, inlineClassName:string): ILineDecoration {
|
||||
return {
|
||||
range: {
|
||||
startLineNumber: startLineNumber,
|
||||
@@ -25,84 +25,84 @@ suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
|
||||
test('Bug 9827:Overlapping inline decorations can cause wrong inline class to be applied', () => {
|
||||
|
||||
var result = ViewLineParts.LineDecorationsNormalizer.normalize(1, [
|
||||
var result = LineDecorationsNormalizer.normalize(1, [
|
||||
newDecoration(1, 1, 1, 11, 'c1'),
|
||||
newDecoration(1, 3, 1, 4, 'c2')
|
||||
]);
|
||||
|
||||
assert.deepEqual(result, [
|
||||
new ViewLineParts.DecorationSegment(0, 1, 'c1'),
|
||||
new ViewLineParts.DecorationSegment(2, 2, 'c2 c1'),
|
||||
new ViewLineParts.DecorationSegment(3, 9, 'c1'),
|
||||
new DecorationSegment(0, 1, 'c1'),
|
||||
new DecorationSegment(2, 2, 'c2 c1'),
|
||||
new DecorationSegment(3, 9, 'c1'),
|
||||
]);
|
||||
});
|
||||
|
||||
test('ViewLineParts', () => {
|
||||
|
||||
assert.deepEqual(ViewLineParts.LineDecorationsNormalizer.normalize(1, [
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
|
||||
newDecoration(1, 1, 1, 2, 'c1'),
|
||||
newDecoration(1, 3, 1, 4, 'c2')
|
||||
]), [
|
||||
new ViewLineParts.DecorationSegment(0, 0, 'c1'),
|
||||
new ViewLineParts.DecorationSegment(2, 2, 'c2')
|
||||
new DecorationSegment(0, 0, 'c1'),
|
||||
new DecorationSegment(2, 2, 'c2')
|
||||
]);
|
||||
|
||||
assert.deepEqual(ViewLineParts.LineDecorationsNormalizer.normalize(1, [
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
|
||||
newDecoration(1, 1, 1, 3, 'c1'),
|
||||
newDecoration(1, 3, 1, 4, 'c2')
|
||||
]), [
|
||||
new ViewLineParts.DecorationSegment(0, 1, 'c1'),
|
||||
new ViewLineParts.DecorationSegment(2, 2, 'c2')
|
||||
new DecorationSegment(0, 1, 'c1'),
|
||||
new DecorationSegment(2, 2, 'c2')
|
||||
]);
|
||||
|
||||
assert.deepEqual(ViewLineParts.LineDecorationsNormalizer.normalize(1, [
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
|
||||
newDecoration(1, 1, 1, 4, 'c1'),
|
||||
newDecoration(1, 3, 1, 4, 'c2')
|
||||
]), [
|
||||
new ViewLineParts.DecorationSegment(0, 1, 'c1'),
|
||||
new ViewLineParts.DecorationSegment(2, 2, 'c1 c2')
|
||||
new DecorationSegment(0, 1, 'c1'),
|
||||
new DecorationSegment(2, 2, 'c1 c2')
|
||||
]);
|
||||
|
||||
assert.deepEqual(ViewLineParts.LineDecorationsNormalizer.normalize(1, [
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
|
||||
newDecoration(1, 1, 1, 4, 'c1'),
|
||||
newDecoration(1, 1, 1, 4, 'c1*'),
|
||||
newDecoration(1, 3, 1, 4, 'c2')
|
||||
]), [
|
||||
new ViewLineParts.DecorationSegment(0, 1, 'c1 c1*'),
|
||||
new ViewLineParts.DecorationSegment(2, 2, 'c1 c1* c2')
|
||||
new DecorationSegment(0, 1, 'c1 c1*'),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c2')
|
||||
]);
|
||||
|
||||
assert.deepEqual(ViewLineParts.LineDecorationsNormalizer.normalize(1, [
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
|
||||
newDecoration(1, 1, 1, 4, 'c1'),
|
||||
newDecoration(1, 1, 1, 4, 'c1*'),
|
||||
newDecoration(1, 1, 1, 4, 'c1**'),
|
||||
newDecoration(1, 3, 1, 4, 'c2')
|
||||
]), [
|
||||
new ViewLineParts.DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new ViewLineParts.DecorationSegment(2, 2, 'c1 c1* c1** c2')
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2')
|
||||
]);
|
||||
|
||||
assert.deepEqual(ViewLineParts.LineDecorationsNormalizer.normalize(1, [
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
|
||||
newDecoration(1, 1, 1, 4, 'c1'),
|
||||
newDecoration(1, 1, 1, 4, 'c1*'),
|
||||
newDecoration(1, 1, 1, 4, 'c1**'),
|
||||
newDecoration(1, 3, 1, 4, 'c2'),
|
||||
newDecoration(1, 3, 1, 4, 'c2*')
|
||||
]), [
|
||||
new ViewLineParts.DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new ViewLineParts.DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*')
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*')
|
||||
]);
|
||||
|
||||
assert.deepEqual(ViewLineParts.LineDecorationsNormalizer.normalize(1, [
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
|
||||
newDecoration(1, 1, 1, 4, 'c1'),
|
||||
newDecoration(1, 1, 1, 4, 'c1*'),
|
||||
newDecoration(1, 1, 1, 4, 'c1**'),
|
||||
newDecoration(1, 3, 1, 4, 'c2'),
|
||||
newDecoration(1, 3, 1, 5, 'c2*')
|
||||
]), [
|
||||
new ViewLineParts.DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new ViewLineParts.DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*'),
|
||||
new ViewLineParts.DecorationSegment(3, 3, 'c2*')
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*'),
|
||||
new DecorationSegment(3, 3, 'c2*')
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import {renderLine} from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import * as assert from 'assert';
|
||||
import {ILineToken} from 'vs/editor/common/editorCommon';
|
||||
import {renderLine} from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
|
||||
suite('viewLineRenderer.renderLine', () => {
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import WhitespaceComputer = require('vs/editor/common/viewLayout/whitespaceComputer');
|
||||
import * as assert from 'assert';
|
||||
import {WhitespaceComputer} from 'vs/editor/common/viewLayout/whitespaceComputer';
|
||||
|
||||
suite('Editor ViewLayout - WhitespaceComputer', () => {
|
||||
|
||||
test('WhitespaceComputer', () => {
|
||||
|
||||
var whitespaceComputer = new WhitespaceComputer.WhitespaceComputer();
|
||||
var whitespaceComputer = new WhitespaceComputer();
|
||||
|
||||
// Insert a whitespace after line number 2, of height 10
|
||||
var a = whitespaceComputer.insertWhitespace(2, 0, 10);
|
||||
@@ -257,127 +257,127 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
|
||||
|
||||
arr = [];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 0);
|
||||
|
||||
arr = [1];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
|
||||
arr = [1, 3];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
|
||||
arr = [1, 3, 5];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
|
||||
arr = [1, 3, 5];
|
||||
ordinals = makeArray(arr.length, 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
|
||||
arr = [1, 3, 5, 7];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
|
||||
arr = [1, 3, 5, 7, 9];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
|
||||
|
||||
arr = [1, 3, 5, 7, 9, 11];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 11, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 12, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 11, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 12, ordinals, 0), 6);
|
||||
|
||||
arr = [1, 3, 5, 7, 9, 11, 13];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 11, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 12, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 13, ordinals, 0), 7);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 14, ordinals, 0), 7);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 11, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 12, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 13, ordinals, 0), 7);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 14, ordinals, 0), 7);
|
||||
|
||||
arr = [1, 3, 5, 7, 9, 11, 13, 15];
|
||||
ordinals = makeArray(arr.length, 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 11, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 12, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 13, ordinals, 0), 7);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 14, ordinals, 0), 7);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 15, ordinals, 0), 8);
|
||||
assert.equal(WhitespaceComputer.WhitespaceComputer.findInsertionIndex(arr, 16, ordinals, 0), 8);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 11, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 12, ordinals, 0), 6);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 13, ordinals, 0), 7);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 14, ordinals, 0), 7);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 15, ordinals, 0), 8);
|
||||
assert.equal(WhitespaceComputer.findInsertionIndex(arr, 16, ordinals, 0), 8);
|
||||
});
|
||||
|
||||
test('WhitespaceComputer changeAfterLineNumberForWhitespace & getFirstWhitespaceIndexAfterLineNumber', () => {
|
||||
var whitespaceComputer = new WhitespaceComputer.WhitespaceComputer();
|
||||
var whitespaceComputer = new WhitespaceComputer();
|
||||
|
||||
var a = whitespaceComputer.insertWhitespace(0, 0, 1);
|
||||
var b = whitespaceComputer.insertWhitespace(7, 0, 1);
|
||||
@@ -502,7 +502,7 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
|
||||
|
||||
|
||||
test('WhitespaceComputer Bug', () => {
|
||||
var whitespaceComputer = new WhitespaceComputer.WhitespaceComputer();
|
||||
var whitespaceComputer = new WhitespaceComputer();
|
||||
|
||||
var a = whitespaceComputer.insertWhitespace(0, 0, 1);
|
||||
var b = whitespaceComputer.insertWhitespace(7, 0, 1);
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import CharacterHardWrappingLineMapper = require('vs/editor/common/viewModel/characterHardWrappingLineMapper');
|
||||
import SplitLinesCollection = require('vs/editor/common/viewModel/splitLinesCollection');
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as assert from 'assert';
|
||||
import {WrappingIndent} from 'vs/editor/common/editorCommon';
|
||||
import {CharacterHardWrappingLineMapperFactory} from 'vs/editor/common/viewModel/characterHardWrappingLineMapper';
|
||||
import {ILineMapperFactory, ILineMapping, IOutputPosition} from 'vs/editor/common/viewModel/splitLinesCollection';
|
||||
|
||||
function safeGetOutputLineCount(mapper:SplitLinesCollection.ILineMapping): number {
|
||||
function safeGetOutputLineCount(mapper:ILineMapping): number {
|
||||
if (!mapper) {
|
||||
return 1;
|
||||
}
|
||||
return mapper.getOutputLineCount();
|
||||
}
|
||||
|
||||
function safeGetOutputPositionOfInputOffset(mapper:SplitLinesCollection.ILineMapping, inputOffset:number, result:SplitLinesCollection.IOutputPosition): void {
|
||||
function safeGetOutputPositionOfInputOffset(mapper:ILineMapping, inputOffset:number, result:IOutputPosition): void {
|
||||
if (!mapper) {
|
||||
result.outputLineIndex = 0;
|
||||
result.outputOffset = inputOffset;
|
||||
@@ -25,14 +25,14 @@ function safeGetOutputPositionOfInputOffset(mapper:SplitLinesCollection.ILineMap
|
||||
mapper.getOutputPositionOfInputOffset(inputOffset, result);
|
||||
}
|
||||
|
||||
function safeGetInputOffsetOfOutputPosition(mapper:SplitLinesCollection.ILineMapping, outputLineIndex:number, outputOffset:number): number {
|
||||
function safeGetInputOffsetOfOutputPosition(mapper:ILineMapping, outputLineIndex:number, outputOffset:number): number {
|
||||
if (!mapper) {
|
||||
return outputOffset;
|
||||
}
|
||||
return mapper.getInputOffsetOfOutputPosition(outputLineIndex, outputOffset);
|
||||
}
|
||||
|
||||
function assertMappingIdentity(mapper:SplitLinesCollection.ILineMapping, offset:number, expectedLineIndex:number) {
|
||||
function assertMappingIdentity(mapper:ILineMapping, offset:number, expectedLineIndex:number) {
|
||||
|
||||
var result = {
|
||||
outputLineIndex: -1,
|
||||
@@ -48,7 +48,7 @@ function assertMappingIdentity(mapper:SplitLinesCollection.ILineMapping, offset:
|
||||
assert.equal(actualOffset, offset);
|
||||
}
|
||||
|
||||
function assertLineMapping(factory:SplitLinesCollection.ILineMapperFactory, tabSize:number, breakAfter:number, annotatedText:string) {
|
||||
function assertLineMapping(factory:ILineMapperFactory, tabSize:number, breakAfter:number, annotatedText:string) {
|
||||
|
||||
var rawText = '';
|
||||
var currentLineIndex = 0;
|
||||
@@ -62,7 +62,7 @@ function assertLineMapping(factory:SplitLinesCollection.ILineMapperFactory, tabS
|
||||
}
|
||||
}
|
||||
|
||||
var mapper = factory.createLineMapping(rawText, tabSize, breakAfter, 1, EditorCommon.WrappingIndent.None);
|
||||
var mapper = factory.createLineMapping(rawText, tabSize, breakAfter, 1, WrappingIndent.None);
|
||||
|
||||
assert.equal(safeGetOutputLineCount(mapper), (lineIndices.length > 0 ? lineIndices[lineIndices.length - 1] + 1 : 1));
|
||||
for (var i = 0, len = rawText.length; i < len; i++) {
|
||||
@@ -73,7 +73,7 @@ function assertLineMapping(factory:SplitLinesCollection.ILineMapperFactory, tabS
|
||||
suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
|
||||
test('CharacterHardWrappingLineMapper', () => {
|
||||
|
||||
var factory = new CharacterHardWrappingLineMapper.CharacterHardWrappingLineMapperFactory('(', ')', '.');
|
||||
var factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.');
|
||||
|
||||
// Empty string
|
||||
assertLineMapping(factory, 4, 5, '');
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import PrefixSumComputer = require('vs/editor/common/viewModel/prefixSumComputer');
|
||||
import * as assert from 'assert';
|
||||
import {IPrefixSumIndexOfResult, PrefixSumComputer} from 'vs/editor/common/viewModel/prefixSumComputer';
|
||||
|
||||
suite('Editor ViewModel - PrefixSumComputer', () => {
|
||||
|
||||
test('PrefixSumComputer', () => {
|
||||
var indexOfResult:PrefixSumComputer.IPrefixSumIndexOfResult = {
|
||||
var indexOfResult:IPrefixSumIndexOfResult = {
|
||||
index: 0,
|
||||
remainder: 0
|
||||
};
|
||||
|
||||
var psc = new PrefixSumComputer.PrefixSumComputer([1, 1, 2, 1, 3]);
|
||||
var psc = new PrefixSumComputer([1, 1, 2, 1, 3]);
|
||||
assert.equal(psc.getTotalValue(), 8);
|
||||
assert.equal(psc.getAccumulatedValue(-1), 0);
|
||||
assert.equal(psc.getAccumulatedValue(0), 1);
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import SplitLinesCollection = require('vs/editor/common/viewModel/splitLinesCollection');
|
||||
import CharacterHardWrappingLineMapper = require('vs/editor/common/viewModel/characterHardWrappingLineMapper');
|
||||
import PrefixSumComputer = require('vs/editor/common/viewModel/prefixSumComputer');
|
||||
import Position = require('vs/editor/common/core/position');
|
||||
import * as assert from 'assert';
|
||||
import {Position} from 'vs/editor/common/core/position';
|
||||
import {CharacterHardWrappingLineMapping} from 'vs/editor/common/viewModel/characterHardWrappingLineMapper';
|
||||
import {PrefixSumComputer} from 'vs/editor/common/viewModel/prefixSumComputer';
|
||||
import {ILineMapping, IModel, SplitLine} from 'vs/editor/common/viewModel/splitLinesCollection';
|
||||
|
||||
suite('Editor ViewModel - SplitLinesCollection', () => {
|
||||
test('SplitLine', () => {
|
||||
@@ -79,19 +79,19 @@ suite('Editor ViewModel - SplitLinesCollection', () => {
|
||||
});
|
||||
|
||||
|
||||
function pos(lineNumber: number, column: number): Position.Position {
|
||||
return new Position.Position(lineNumber, column);
|
||||
function pos(lineNumber: number, column: number): Position {
|
||||
return new Position(lineNumber, column);
|
||||
}
|
||||
|
||||
function createSplitLine(splitLengths:number[], wrappedLinesPrefix:string, isVisible: boolean = true): SplitLinesCollection.SplitLine {
|
||||
return new SplitLinesCollection.SplitLine(createLineMapping(splitLengths, wrappedLinesPrefix), isVisible);
|
||||
function createSplitLine(splitLengths:number[], wrappedLinesPrefix:string, isVisible: boolean = true): SplitLine {
|
||||
return new SplitLine(createLineMapping(splitLengths, wrappedLinesPrefix), isVisible);
|
||||
}
|
||||
|
||||
function createLineMapping(breakingLengths:number[], wrappedLinesPrefix:string): SplitLinesCollection.ILineMapping {
|
||||
return new CharacterHardWrappingLineMapper.CharacterHardWrappingLineMapping(new PrefixSumComputer.PrefixSumComputer(breakingLengths), wrappedLinesPrefix);
|
||||
function createLineMapping(breakingLengths:number[], wrappedLinesPrefix:string): ILineMapping {
|
||||
return new CharacterHardWrappingLineMapping(new PrefixSumComputer(breakingLengths), wrappedLinesPrefix);
|
||||
}
|
||||
|
||||
function createModel(text:string): SplitLinesCollection.IModel {
|
||||
function createModel(text:string): IModel {
|
||||
return {
|
||||
getLineTokens: (lineNumber:number, inaccurateTokensAcceptable?:boolean) => {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user