Skip to content

Commit

Permalink
Have the default be TextBufferType.LinesArray, add VSCODE_PIECE_TREE env
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jan 29, 2018
1 parent 1c32b21 commit 1cdf4ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 8 additions & 1 deletion src/vs/workbench/parts/codeEditor/codeEditor.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ import './electron-browser/toggleMinimap';
import './electron-browser/toggleMultiCursorModifier';
import './electron-browser/toggleRenderControlCharacter';
import './electron-browser/toggleRenderWhitespace';
import './electron-browser/toggleWordWrap';
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;
}

0 comments on commit 1cdf4ae

Please sign in to comment.