From 39313c13571417fec88b5c325aa14667da2b9af9 Mon Sep 17 00:00:00 2001 From: mechatroner Date: Sat, 3 Mar 2018 16:16:56 -0500 Subject: [PATCH 1/3] move huge file params to user config for Microsoft/vscode#44986 --- .../common/config/commonEditorConfig.ts | 10 + src/vs/editor/common/config/editorOptions.ts | 4 +- src/vs/editor/common/model.ts | 2 + src/vs/editor/common/model/textModel.ts | 10 +- .../common/services/modelServiceImpl.ts | 22 ++- .../test/linesOperations.test.ts | 5 +- .../test/browser/controller/cursor.test.ts | 180 ++++++++++++------ .../test/common/model/textModel.test.ts | 13 +- 8 files changed, 175 insertions(+), 71 deletions(-) diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 73339f9d245..2f7729f226f 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -653,6 +653,16 @@ const editorConfiguration: IConfigurationNode = { 'default': true, 'description': nls.localize('ignoreTrimWhitespace', "Controls if the diff editor shows changes in leading or trailing whitespace as diffs") }, + 'editor.hugeFileSize': { + 'type': 'number', + 'default': EDITOR_MODEL_DEFAULTS.hugeFileSize, + 'description': nls.localize('hugeFileSize', "Controls file size threshold in bytes beyond which special optimization rules are applied") + }, + 'editor.hugeFileNumLines': { + 'type': 'number', + 'default': EDITOR_MODEL_DEFAULTS.hugeFileNumLines, + 'description': nls.localize('hugeFileNumLines', "Controls file size threshold in terms of line count beyond which special optimization rules are applied") + }, 'diffEditor.renderIndicators': { 'type': 'boolean', 'default': true, diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 921165fc844..1743f790159 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -2172,7 +2172,9 @@ export const EDITOR_MODEL_DEFAULTS = { tabSize: 4, insertSpaces: true, detectIndentation: true, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: 20 * 1024 * 1024, // 20 MB + hugeFileNumLines: 300 * 1000 // 300K lines }; /** diff --git a/src/vs/editor/common/model.ts b/src/vs/editor/common/model.ts index bf6ecbbee7c..4e870a213be 100644 --- a/src/vs/editor/common/model.ts +++ b/src/vs/editor/common/model.ts @@ -389,6 +389,8 @@ export interface ITextModelCreationOptions { detectIndentation: boolean; trimAutoWhitespace: boolean; defaultEOL: DefaultEndOfLine; + hugeFileSize: number; + hugeFileNumLines: number; } export interface ITextModelUpdateOptions { diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index 982916e15f8..86be54f8fe7 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -173,8 +173,8 @@ class TextModelSnapshot implements ITextSnapshot { export class TextModel extends Disposable implements model.ITextModel { private static readonly MODEL_SYNC_LIMIT = 50 * 1024 * 1024; // 50 MB - private static readonly MODEL_TOKENIZATION_LIMIT = 20 * 1024 * 1024; // 20 MB - private static readonly MANY_MANY_LINES = 300 * 1000; // 300K lines + //private static readonly MODEL_TOKENIZATION_LIMIT = 20 * 1024 * 1024; // 20 MB + //private static readonly MANY_MANY_LINES = 300 * 1000; // 300K lines public static DEFAULT_CREATION_OPTIONS: model.ITextModelCreationOptions = { tabSize: EDITOR_MODEL_DEFAULTS.tabSize, @@ -182,6 +182,8 @@ export class TextModel extends Disposable implements model.ITextModel { detectIndentation: false, defaultEOL: model.DefaultEndOfLine.LF, trimAutoWhitespace: EDITOR_MODEL_DEFAULTS.trimAutoWhitespace, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines, }; public static createFromString(text: string, options: model.ITextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS, languageIdentifier: LanguageIdentifier = null, uri: URI = null): TextModel { @@ -301,8 +303,8 @@ export class TextModel extends Disposable implements model.ITextModel { // If a model is too large at construction time, it will never get tokenized, // under no circumstances. this._isTooLargeForTokenization = ( - (bufferTextLength > TextModel.MODEL_TOKENIZATION_LIMIT) - || (bufferLineCount > TextModel.MANY_MANY_LINES) + (bufferTextLength > creationOptions.hugeFileSize) + || (bufferLineCount > creationOptions.hugeFileNumLines) ); this._shouldSimplifyMode = ( diff --git a/src/vs/editor/common/services/modelServiceImpl.ts b/src/vs/editor/common/services/modelServiceImpl.ts index 82a54629774..ff5c1e3fb3b 100644 --- a/src/vs/editor/common/services/modelServiceImpl.ts +++ b/src/vs/editor/common/services/modelServiceImpl.ts @@ -181,6 +181,8 @@ interface IRawConfig { insertSpaces?: any; detectIndentation?: any; trimAutoWhitespace?: any; + hugeFileSize?: any; + hugeFileNumLines?: any; }; } @@ -259,12 +261,30 @@ export class ModelServiceImpl implements IModelService { detectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation)); } + let hugeFileSize = EDITOR_MODEL_DEFAULTS.hugeFileSize; + if (config.editor && typeof config.editor.hugeFileSize !== 'undefined') { + let parsedHugeFileSize = parseInt(config.editor.hugeFileSize, 10); + if (!isNaN(parsedHugeFileSize)) { + hugeFileSize = parsedHugeFileSize; + } + } + + let hugeFileNumLines = EDITOR_MODEL_DEFAULTS.hugeFileNumLines; + if (config.editor && typeof config.editor.hugeFileNumLines !== 'undefined') { + let parsedHugeFileNumLines = parseInt(config.editor.hugeFileNumLines, 10); + if (!isNaN(parsedHugeFileNumLines)) { + hugeFileNumLines = parsedHugeFileNumLines; + } + } + return { tabSize: tabSize, insertSpaces: insertSpaces, detectIndentation: detectIndentation, defaultEOL: newDefaultEOL, - trimAutoWhitespace: trimAutoWhitespace + trimAutoWhitespace: trimAutoWhitespace, + hugeFileSize: hugeFileSize, + hugeFileNumLines: hugeFileNumLines }; } diff --git a/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts b/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts index b867a47ed61..190ff557445 100644 --- a/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts +++ b/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts @@ -9,6 +9,7 @@ import { Selection } from 'vs/editor/common/core/selection'; import { Position } from 'vs/editor/common/core/position'; import { Handler } from 'vs/editor/common/editorCommon'; import { ITextModel, DefaultEndOfLine } from 'vs/editor/common/model'; +import { EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions'; import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { DeleteAllLeftAction, JoinLinesAction, TransposeAction, UpperCaseAction, LowerCaseAction, DeleteAllRightAction, InsertLineBeforeAction, InsertLineAfterAction, IndentLinesAction, SortLinesAscendingAction, SortLinesDescendingAction } from 'vs/editor/contrib/linesOperations/linesOperations'; import { Cursor } from 'vs/editor/common/controller/cursor'; @@ -755,7 +756,9 @@ suite('Editor Contrib - Line Operations', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); diff --git a/src/vs/editor/test/browser/controller/cursor.test.ts b/src/vs/editor/test/browser/controller/cursor.test.ts index 4f688aa088c..c62f2d4a199 100644 --- a/src/vs/editor/test/browser/controller/cursor.test.ts +++ b/src/vs/editor/test/browser/controller/cursor.test.ts @@ -18,7 +18,7 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; import { MockMode } from 'vs/editor/test/common/mocks/mockMode'; import { LanguageIdentifier } from 'vs/editor/common/modes'; -import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions'; import { CoreNavigationCommands, CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands'; import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl'; @@ -1138,7 +1138,9 @@ suite('Editor Controller - Regression tests', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: false + trimAutoWhitespace: false, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, ); @@ -1163,7 +1165,9 @@ suite('Editor Controller - Regression tests', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: false + trimAutoWhitespace: false, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, ); @@ -1228,7 +1232,9 @@ suite('Editor Controller - Regression tests', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); @@ -1256,7 +1262,9 @@ suite('Editor Controller - Regression tests', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -1288,7 +1296,9 @@ suite('Editor Controller - Regression tests', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, ); @@ -1349,7 +1359,7 @@ suite('Editor Controller - Regression tests', () => { 'hello' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { tabSize: 4, insertSpaces: true, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { tabSize: 4, insertSpaces: true, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 1, 3, false); moveTo(cursor, 1, 5, true); @@ -1377,7 +1387,9 @@ suite('Editor Controller - Regression tests', () => { insertSpaces: true, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, ); @@ -1498,7 +1510,9 @@ suite('Editor Controller - Regression tests', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -1552,7 +1566,7 @@ suite('Editor Controller - Regression tests', () => { 'just some text', ], languageIdentifier: null, - modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 1, false); @@ -1580,7 +1594,9 @@ suite('Editor Controller - Regression tests', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -1604,7 +1620,9 @@ suite('Editor Controller - Regression tests', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -1917,7 +1935,9 @@ suite('Editor Controller - Regression tests', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -1947,7 +1967,7 @@ suite('Editor Controller - Cursor Configuration', () => { '', '1' ], - modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { CoreNavigationCommands.MoveTo.runCoreEditorCommand(cursor, { position: new Position(1, 21), source: 'keyboard' }); cursorCommand(cursor, H.Type, { text: '\n' }, 'keyboard'); @@ -1970,7 +1990,9 @@ suite('Editor Controller - Cursor Configuration', () => { tabSize: 13, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -2040,7 +2062,7 @@ suite('Editor Controller - Cursor Configuration', () => { '\thello' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 1, 7, false); assertCursor(cursor, new Selection(1, 7, 1, 7)); @@ -2058,7 +2080,7 @@ suite('Editor Controller - Cursor Configuration', () => { '\thello' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 1, 7, false); assertCursor(cursor, new Selection(1, 7, 1, 7)); @@ -2076,7 +2098,7 @@ suite('Editor Controller - Cursor Configuration', () => { '\thell()' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 1, 7, false); assertCursor(cursor, new Selection(1, 7, 1, 7)); @@ -2097,7 +2119,9 @@ suite('Editor Controller - Cursor Configuration', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: false + trimAutoWhitespace: false, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { @@ -2125,7 +2149,9 @@ suite('Editor Controller - Cursor Configuration', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 1, model.getLineContent(1).length + 1); @@ -2151,7 +2177,9 @@ suite('Editor Controller - Cursor Configuration', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, languageIdentifier: mode.getLanguageIdentifier(), }, (model, cursor) => { @@ -2199,7 +2227,9 @@ suite('Editor Controller - Cursor Configuration', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -2243,7 +2273,9 @@ suite('Editor Controller - Cursor Configuration', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -2309,7 +2341,9 @@ suite('Editor Controller - Cursor Configuration', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -2335,7 +2369,9 @@ suite('Editor Controller - Cursor Configuration', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -2406,7 +2442,9 @@ suite('Editor Controller - Cursor Configuration', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -2482,7 +2520,7 @@ suite('Editor Controller - Indentation Rules', () => { '\tif (true) {' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true }, + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, editorOpts: { autoIndent: true } }, (model, cursor) => { moveTo(cursor, 1, 12, false); @@ -2506,7 +2544,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true }, + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, editorOpts: { autoIndent: true } }, (model, cursor) => { moveTo(cursor, 2, 2, false); @@ -2525,7 +2563,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t\t\treturn true' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true }, + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, editorOpts: { autoIndent: true } }, (model, cursor) => { moveTo(cursor, 2, 15, false); @@ -2545,7 +2583,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t\t\t\treturn true' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true }, + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, editorOpts: { autoIndent: true } }, (model, cursor) => { moveTo(cursor, 2, 14, false); @@ -2573,7 +2611,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); @@ -2602,7 +2642,7 @@ suite('Editor Controller - Indentation Rules', () => { '}}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true }, + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, editorOpts: { autoIndent: true } }, (model, cursor) => { moveTo(cursor, 3, 13, false); @@ -2623,7 +2663,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t}a}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 4, 3, false); moveTo(cursor, 4, 4, true); @@ -2642,7 +2682,7 @@ suite('Editor Controller - Indentation Rules', () => { '\tif (true) {' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 2, 12, false); moveTo(cursor, 2, 13, true); @@ -2663,7 +2703,7 @@ suite('Editor Controller - Indentation Rules', () => { '\tif (true) {' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 1, 12, false); assertCursor(cursor, new Selection(1, 12, 1, 12)); @@ -2688,7 +2728,7 @@ suite('Editor Controller - Indentation Rules', () => { ' if (true) {' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 1, 12, false); assertCursor(cursor, new Selection(1, 12, 1, 12)); @@ -2712,7 +2752,7 @@ suite('Editor Controller - Indentation Rules', () => { ' if (true) {' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 1, 12, false); assertCursor(cursor, new Selection(1, 12, 1, 12)); @@ -2740,7 +2780,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true }, + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, editorOpts: { autoIndent: true } }, (model, cursor) => { moveTo(cursor, 5, 4, false); @@ -2761,7 +2801,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t}a}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 9, false); assertCursor(cursor, new Selection(3, 9, 3, 9)); @@ -2781,7 +2821,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t}a}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 3, false); assertCursor(cursor, new Selection(3, 3, 3, 3)); @@ -2801,7 +2841,7 @@ suite('Editor Controller - Indentation Rules', () => { ' }a}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 2, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 2, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 11, false); assertCursor(cursor, new Selection(3, 11, 3, 11)); @@ -2821,7 +2861,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t}a}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 2, false); assertCursor(cursor, new Selection(3, 2, 3, 2)); @@ -2848,7 +2888,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t\t}a}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 4, false); assertCursor(cursor, new Selection(3, 4, 3, 4)); @@ -2875,7 +2915,7 @@ suite('Editor Controller - Indentation Rules', () => { '}a}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 2, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 2, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 2, false); assertCursor(cursor, new Selection(3, 2, 3, 2)); @@ -2905,7 +2945,7 @@ suite('Editor Controller - Indentation Rules', () => { '}a}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 2, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 2, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 3, false); assertCursor(cursor, new Selection(3, 3, 3, 3)); @@ -2931,7 +2971,7 @@ suite('Editor Controller - Indentation Rules', () => { '' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: true, tabSize: 2, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: true, tabSize: 2, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 5, false); moveTo(cursor, 4, 3, true); @@ -2956,7 +2996,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, languageIdentifier: mode.getLanguageIdentifier(), }, (model, cursor) => { @@ -2983,7 +3025,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, languageIdentifier: mode.getLanguageIdentifier(), }, (model, cursor) => { @@ -3007,7 +3051,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t}', '?>' ], - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 5, 3, false); assertCursor(cursor, new Selection(5, 3, 5, 3)); @@ -3026,7 +3070,7 @@ suite('Editor Controller - Indentation Rules', () => { ' return 5;', ' ' ], - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 3, 2, false); assertCursor(cursor, new Selection(3, 2, 3, 2)); @@ -3052,7 +3096,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); @@ -3084,7 +3130,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); @@ -3116,7 +3164,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); @@ -3147,7 +3197,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); @@ -3178,7 +3230,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: false, tabSize: 4, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); @@ -3209,7 +3263,9 @@ suite('Editor Controller - Indentation Rules', () => { tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); @@ -3245,7 +3301,9 @@ suite('Editor Controller - Indentation Rules', () => { detectIndentation: false, insertSpaces: true, tabSize: 2, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, rubyMode.getLanguageIdentifier() ); @@ -3272,7 +3330,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 5, 3, false); assertCursor(cursor, new Selection(5, 3, 5, 3)); @@ -3294,7 +3352,7 @@ suite('Editor Controller - Indentation Rules', () => { '}' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true } + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } }, (model, cursor) => { moveTo(cursor, 2, 3, false); assertCursor(cursor, new Selection(2, 3, 2, 3)); @@ -3313,7 +3371,7 @@ suite('Editor Controller - Indentation Rules', () => { '\t\t' ], languageIdentifier: mode.getLanguageIdentifier(), - modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true }, + modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, editorOpts: { autoIndent: true } }, (model, cursor) => { moveTo(cursor, 3, 3, false); @@ -3444,7 +3502,7 @@ suite('Editor Controller - Indentation Rules', () => { '', ')', ].join('\n'), - { insertSpaces: true, detectIndentation: false, tabSize: 2, trimAutoWhitespace: false, defaultEOL: DefaultEndOfLine.LF }, + { insertSpaces: true, detectIndentation: false, tabSize: 2, trimAutoWhitespace: false, defaultEOL: DefaultEndOfLine.LF, hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines }, mode.getLanguageIdentifier() ); diff --git a/src/vs/editor/test/common/model/textModel.test.ts b/src/vs/editor/test/common/model/textModel.test.ts index a99bde0f438..d1040c791cb 100644 --- a/src/vs/editor/test/common/model/textModel.test.ts +++ b/src/vs/editor/test/common/model/textModel.test.ts @@ -10,6 +10,7 @@ import { Range } from 'vs/editor/common/core/range'; import { TextModel, createTextBuffer } from 'vs/editor/common/model/textModel'; import { DefaultEndOfLine } from 'vs/editor/common/model'; import { UTF8_BOM_CHARACTER } from 'vs/base/common/strings'; +import { EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions'; function testGuessIndentation(defaultInsertSpaces: boolean, defaultTabSize: number, expectedInsertSpaces: boolean, expectedTabSize: number, text: string[], msg?: string): void { var m = TextModel.createFromString( @@ -19,7 +20,9 @@ function testGuessIndentation(defaultInsertSpaces: boolean, defaultTabSize: numb insertSpaces: defaultInsertSpaces, detectIndentation: true, defaultEOL: DefaultEndOfLine.LF, - trimAutoWhitespace: true + trimAutoWhitespace: true, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); var r = m.getOptions(); @@ -711,7 +714,9 @@ suite('Editor Model - TextModel', () => { tabSize: 4, insertSpaces: false, trimAutoWhitespace: true, - defaultEOL: DefaultEndOfLine.LF + defaultEOL: DefaultEndOfLine.LF, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); @@ -747,7 +752,9 @@ suite('Editor Model - TextModel', () => { tabSize: 4, insertSpaces: true, trimAutoWhitespace: true, - defaultEOL: DefaultEndOfLine.LF + defaultEOL: DefaultEndOfLine.LF, + hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, + hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines } ); From 1a853daec42516afef06482d27d41170e019f378 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 9 Apr 2018 10:19:46 +0200 Subject: [PATCH 2/3] Rename options --- .../common/config/commonEditorConfig.ts | 12 ++++---- src/vs/editor/common/config/editorOptions.ts | 4 +-- src/vs/editor/common/model.ts | 4 +-- src/vs/editor/common/model/textModel.ts | 10 +++---- .../common/services/modelServiceImpl.ts | 28 +++++++++---------- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 6ea7f0c2c28..3c463fe6c46 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -668,15 +668,15 @@ const editorConfiguration: IConfigurationNode = { 'default': true, 'description': nls.localize('ignoreTrimWhitespace', "Controls if the diff editor shows changes in leading or trailing whitespace as diffs") }, - 'editor.hugeFileSize': { + 'editor.largeFileSize': { 'type': 'number', - 'default': EDITOR_MODEL_DEFAULTS.hugeFileSize, - 'description': nls.localize('hugeFileSize', "Controls file size threshold in bytes beyond which special optimization rules are applied") + 'default': EDITOR_MODEL_DEFAULTS.largeFileSize, + 'description': nls.localize('largeFileSize', "Controls file size threshold in bytes beyond which special optimization rules are applied") }, - 'editor.hugeFileNumLines': { + 'editor.largeFileLineCount': { 'type': 'number', - 'default': EDITOR_MODEL_DEFAULTS.hugeFileNumLines, - 'description': nls.localize('hugeFileNumLines', "Controls file size threshold in terms of line count beyond which special optimization rules are applied") + 'default': EDITOR_MODEL_DEFAULTS.largeFileLineCount, + 'description': nls.localize('largeFileLineCount', "Controls file size threshold in terms of line count beyond which special optimization rules are applied") }, 'diffEditor.renderIndicators': { 'type': 'boolean', diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 6bac3b3fa5d..48d76961005 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -2205,8 +2205,8 @@ export const EDITOR_MODEL_DEFAULTS = { insertSpaces: true, detectIndentation: true, trimAutoWhitespace: true, - hugeFileSize: 20 * 1024 * 1024, // 20 MB - hugeFileNumLines: 300 * 1000 // 300K lines + largeFileSize: 20 * 1024 * 1024, // 20 MB + largeFileLineCount: 300 * 1000 // 300K lines }; /** diff --git a/src/vs/editor/common/model.ts b/src/vs/editor/common/model.ts index a9345fa3471..b8c7a186cae 100644 --- a/src/vs/editor/common/model.ts +++ b/src/vs/editor/common/model.ts @@ -396,8 +396,8 @@ export interface ITextModelCreationOptions { trimAutoWhitespace: boolean; defaultEOL: DefaultEndOfLine; isForSimpleWidget: boolean; - hugeFileSize: number; - hugeFileNumLines: number; + largeFileSize: number; + largeFileLineCount: number; } export interface ITextModelUpdateOptions { diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index 55bdf285014..53d6bc2df0e 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -155,8 +155,6 @@ class TextModelSnapshot implements ITextSnapshot { export class TextModel extends Disposable implements model.ITextModel { private static readonly MODEL_SYNC_LIMIT = 50 * 1024 * 1024; // 50 MB - //private static readonly MODEL_TOKENIZATION_LIMIT = 20 * 1024 * 1024; // 20 MB - //private static readonly MANY_MANY_LINES = 300 * 1000; // 300K lines public static DEFAULT_CREATION_OPTIONS: model.ITextModelCreationOptions = { isForSimpleWidget: false, @@ -165,8 +163,8 @@ export class TextModel extends Disposable implements model.ITextModel { detectIndentation: false, defaultEOL: model.DefaultEndOfLine.LF, trimAutoWhitespace: EDITOR_MODEL_DEFAULTS.trimAutoWhitespace, - hugeFileSize: EDITOR_MODEL_DEFAULTS.hugeFileSize, - hugeFileNumLines: EDITOR_MODEL_DEFAULTS.hugeFileNumLines, + largeFileSize: EDITOR_MODEL_DEFAULTS.largeFileSize, + largeFileLineCount: EDITOR_MODEL_DEFAULTS.largeFileLineCount, }; public static createFromString(text: string, options: model.ITextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS, languageIdentifier: LanguageIdentifier = null, uri: URI = null): TextModel { @@ -291,8 +289,8 @@ export class TextModel extends Disposable implements model.ITextModel { // If a model is too large at construction time, it will never get tokenized, // under no circumstances. this._isTooLargeForTokenization = ( - (bufferTextLength > creationOptions.hugeFileSize) - || (bufferLineCount > creationOptions.hugeFileNumLines) + (bufferTextLength > creationOptions.largeFileSize) + || (bufferLineCount > creationOptions.largeFileLineCount) ); this._shouldSimplifyMode = ( diff --git a/src/vs/editor/common/services/modelServiceImpl.ts b/src/vs/editor/common/services/modelServiceImpl.ts index fc5554c392e..b189ac8390c 100644 --- a/src/vs/editor/common/services/modelServiceImpl.ts +++ b/src/vs/editor/common/services/modelServiceImpl.ts @@ -197,8 +197,8 @@ interface IRawConfig { insertSpaces?: any; detectIndentation?: any; trimAutoWhitespace?: any; - hugeFileSize?: any; - hugeFileNumLines?: any; + largeFileSize?: any; + largeFileLineCount?: any; }; } @@ -277,19 +277,19 @@ export class ModelServiceImpl implements IModelService { detectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation)); } - let hugeFileSize = EDITOR_MODEL_DEFAULTS.hugeFileSize; - if (config.editor && typeof config.editor.hugeFileSize !== 'undefined') { - let parsedHugeFileSize = parseInt(config.editor.hugeFileSize, 10); - if (!isNaN(parsedHugeFileSize)) { - hugeFileSize = parsedHugeFileSize; + let largeFileSize = EDITOR_MODEL_DEFAULTS.largeFileSize; + if (config.editor && typeof config.editor.largeFileSize !== 'undefined') { + let parsedlargeFileSize = parseInt(config.editor.largeFileSize, 10); + if (!isNaN(parsedlargeFileSize)) { + largeFileSize = parsedlargeFileSize; } } - let hugeFileNumLines = EDITOR_MODEL_DEFAULTS.hugeFileNumLines; - if (config.editor && typeof config.editor.hugeFileNumLines !== 'undefined') { - let parsedHugeFileNumLines = parseInt(config.editor.hugeFileNumLines, 10); - if (!isNaN(parsedHugeFileNumLines)) { - hugeFileNumLines = parsedHugeFileNumLines; + let largeFileLineCount = EDITOR_MODEL_DEFAULTS.largeFileLineCount; + if (config.editor && typeof config.editor.largeFileLineCount !== 'undefined') { + let parsedlargeFileLineCount = parseInt(config.editor.largeFileLineCount, 10); + if (!isNaN(parsedlargeFileLineCount)) { + largeFileLineCount = parsedlargeFileLineCount; } } @@ -300,8 +300,8 @@ export class ModelServiceImpl implements IModelService { detectIndentation: detectIndentation, defaultEOL: newDefaultEOL, trimAutoWhitespace: trimAutoWhitespace, - hugeFileSize: hugeFileSize, - hugeFileNumLines: hugeFileNumLines + largeFileSize: largeFileSize, + largeFileLineCount: largeFileLineCount }; } From e37acd3ceeef6cac41633fb9f0dc0d3ce2be4655 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 9 Apr 2018 10:22:42 +0200 Subject: [PATCH 3/3] Fix tests --- src/vs/editor/test/common/editorTestUtils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vs/editor/test/common/editorTestUtils.ts b/src/vs/editor/test/common/editorTestUtils.ts index 9c7ed1e9826..d2e8cb2072e 100644 --- a/src/vs/editor/test/common/editorTestUtils.ts +++ b/src/vs/editor/test/common/editorTestUtils.ts @@ -22,6 +22,8 @@ export interface IRelaxedTextModelCreationOptions { trimAutoWhitespace?: boolean; defaultEOL?: DefaultEndOfLine; isForSimpleWidget?: boolean; + largeFileSize?: number; + largeFileLineCount?: number; } export function createTextModel(text: string, _options: IRelaxedTextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS, languageIdentifier: LanguageIdentifier = null, uri: URI = null): TextModel { @@ -32,6 +34,8 @@ export function createTextModel(text: string, _options: IRelaxedTextModelCreatio trimAutoWhitespace: (typeof _options.trimAutoWhitespace === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.trimAutoWhitespace : _options.trimAutoWhitespace), defaultEOL: (typeof _options.defaultEOL === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.defaultEOL : _options.defaultEOL), isForSimpleWidget: (typeof _options.isForSimpleWidget === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.isForSimpleWidget : _options.isForSimpleWidget), + largeFileSize: (typeof _options.largeFileSize === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.largeFileSize : _options.largeFileSize), + largeFileLineCount: (typeof _options.largeFileLineCount === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.largeFileLineCount : _options.largeFileLineCount), }; return TextModel.createFromString(text, options, languageIdentifier, uri); }