From 1cdf4aec304ada0d7d9409afc54e568a5913cd69 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 29 Jan 2018 17:36:05 +0100 Subject: [PATCH] Have the default be TextBufferType.LinesArray, add VSCODE_PIECE_TREE env --- src/vs/editor/common/model/textModel.ts | 14 ++++++++++---- .../parts/codeEditor/codeEditor.contribution.ts | 9 ++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index d64c382f47edc..f9f3edbe92e54 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -37,15 +37,21 @@ import { LinesTextBufferBuilder } from 'vs/editor/common/model/linesTextBuffer/l import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder'; import { ChunksTextBufferBuilder } from 'vs/editor/common/model/chunksTextBuffer/chunksTextBufferBuilder'; +export enum TextBufferType { + LinesArray, + PieceTree, + Chunks +} // Here is the master switch for the text buffer implementation: -const USE_PIECE_TREE_IMPLEMENTATION = true; -const USE_CHUNKS_TEXT_BUFFER = false; +export const OPTIONS = { + TEXT_BUFFER_IMPLEMENTATION: TextBufferType.LinesArray +}; function createTextBufferBuilder() { - if (USE_PIECE_TREE_IMPLEMENTATION) { + if (OPTIONS.TEXT_BUFFER_IMPLEMENTATION === TextBufferType.PieceTree) { return new PieceTreeTextBufferBuilder(); } - if (USE_CHUNKS_TEXT_BUFFER) { + if (OPTIONS.TEXT_BUFFER_IMPLEMENTATION === TextBufferType.Chunks) { return new ChunksTextBufferBuilder(); } return new LinesTextBufferBuilder(); diff --git a/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts b/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts index 95050238b9319..42d312d8c7e8c 100644 --- a/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts +++ b/src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts @@ -12,4 +12,11 @@ import './electron-browser/toggleMinimap'; import './electron-browser/toggleMultiCursorModifier'; import './electron-browser/toggleRenderControlCharacter'; import './electron-browser/toggleRenderWhitespace'; -import './electron-browser/toggleWordWrap'; \ No newline at end of file +import './electron-browser/toggleWordWrap'; +import { OPTIONS, TextBufferType } from 'vs/editor/common/model/textModel'; + +// Configure text buffer implementation +if (process.env['VSCODE_PIECE_TREE']) { + console.log(`Using TextBufferType.PieceTree (env variable VSCODE_PIECE_TREE)`); + OPTIONS.TEXT_BUFFER_IMPLEMENTATION = TextBufferType.PieceTree; +}