mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
re #42260. use getValueInRange in SplitLine.
This commit is contained in:
parent
7e8cb46194
commit
020afb768d
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { PrefixSumComputerWithCache } from 'vs/editor/common/viewModel/prefixSumComputer';
|
||||
import { ViewLineData, ICoordinatesConverter, IOverviewRulerDecorations } from 'vs/editor/common/viewModel/viewModel';
|
||||
|
@ -14,7 +14,7 @@ import { WrappingIndent } from 'vs/editor/common/config/editorOptions';
|
|||
import { ModelDecorationOptions, ModelDecorationOverviewRulerOptions } from 'vs/editor/common/model/textModel';
|
||||
import { ThemeColor, ITheme } from 'vs/platform/theme/common/themeService';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { IModelDecoration, ITextModel, IModelDeltaDecoration } from 'vs/editor/common/model';
|
||||
import { IModelDecoration, ITextModel, IModelDeltaDecoration, EndOfLinePreference } from 'vs/editor/common/model';
|
||||
|
||||
export class OutputPosition {
|
||||
_outputPositionBrand: void;
|
||||
|
@ -43,6 +43,7 @@ export interface ISimpleModel {
|
|||
getLineContent(lineNumber: number): string;
|
||||
getLineMinColumn(lineNumber: number): number;
|
||||
getLineMaxColumn(lineNumber: number): number;
|
||||
getValueInRange(range: IRange, eol?: EndOfLinePreference): string;
|
||||
}
|
||||
|
||||
export interface ISplitLine {
|
||||
|
@ -947,7 +948,12 @@ export class SplitLine implements ISplitLine {
|
|||
}
|
||||
let startOffset = this.getInputStartOffsetOfOutputLineIndex(outputLineIndex);
|
||||
let endOffset = this.getInputEndOffsetOfOutputLineIndex(model, modelLineNumber, outputLineIndex);
|
||||
let r = model.getLineContent(modelLineNumber).substring(startOffset, endOffset);
|
||||
let r = model.getValueInRange({
|
||||
startLineNumber: modelLineNumber,
|
||||
startColumn: startOffset + 1,
|
||||
endLineNumber: modelLineNumber,
|
||||
endColumn: endOffset + 1
|
||||
});
|
||||
|
||||
if (outputLineIndex > 0) {
|
||||
r = this.wrappedIndent + r;
|
||||
|
@ -956,7 +962,7 @@ export class SplitLine implements ISplitLine {
|
|||
return r;
|
||||
}
|
||||
|
||||
public getViewLineMinColumn(model: ISimpleModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
public getViewLineMinColumn(model: ITextModel, modelLineNumber: number, outputLineIndex: number): number {
|
||||
if (!this._isVisible) {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
|
@ -981,7 +987,13 @@ export class SplitLine implements ISplitLine {
|
|||
let startOffset = this.getInputStartOffsetOfOutputLineIndex(outputLineIndex);
|
||||
let endOffset = this.getInputEndOffsetOfOutputLineIndex(model, modelLineNumber, outputLineIndex);
|
||||
|
||||
let lineContent = model.getLineContent(modelLineNumber).substring(startOffset, endOffset);
|
||||
let lineContent = model.getValueInRange({
|
||||
startLineNumber: modelLineNumber,
|
||||
startColumn: startOffset + 1,
|
||||
endLineNumber: modelLineNumber,
|
||||
endColumn: endOffset + 1
|
||||
});
|
||||
|
||||
if (outputLineIndex > 0) {
|
||||
lineContent = this.wrappedIndent + lineContent;
|
||||
}
|
||||
|
@ -1003,7 +1015,7 @@ export class SplitLine implements ISplitLine {
|
|||
);
|
||||
}
|
||||
|
||||
public getViewLinesData(model: ISimpleModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void {
|
||||
public getViewLinesData(model: ITextModel, modelLineNumber: number, fromOuputLineIndex: number, toOutputLineIndex: number, globalStartIndex: number, needed: boolean[], result: ViewLineData[]): void {
|
||||
if (!this._isVisible) {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
|
|
|
@ -17,8 +17,9 @@ import { NULL_STATE } from 'vs/editor/common/modes/nullMode';
|
|||
import { TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ViewLineData } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { IViewLineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { EndOfLinePreference } from 'vs/editor/common/model';
|
||||
|
||||
suite('Editor ViewModel - SplitLinesCollection', () => {
|
||||
test('SplitLine', () => {
|
||||
|
@ -784,6 +785,9 @@ function createModel(text: string): ISimpleModel {
|
|||
},
|
||||
getLineMaxColumn: (lineNumber: number) => {
|
||||
return text.length + 1;
|
||||
},
|
||||
getValueInRange: (range: IRange, eol?: EndOfLinePreference) => {
|
||||
return text.substring(range.startColumn - 1, range.endColumn - 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue