未验证 提交 be37461e 编写于 作者: A Alex Dima

Fixes #77332: Increase first line limit for mode detaction from 100 to 1000

上级 749a0232
......@@ -1192,6 +1192,13 @@ export interface ITextBufferFactory {
getFirstLineText(lengthLimit: number): string;
}
/**
* @internal
*/
export const enum ModelConstants {
FIRST_LINE_DETECTION_LENGTH_LIMIT = 1000
}
/**
* @internal
*/
......
......@@ -57,7 +57,7 @@ export class PieceTreeTextBufferFactory implements ITextBufferFactory {
}
public getFirstLineText(lengthLimit: number): string {
return this._chunks[0].buffer.substr(0, 100).split(/\r\n|\r|\n/)[0];
return this._chunks[0].buffer.substr(0, lengthLimit).split(/\r\n|\r|\n/)[0];
}
}
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ITextModel, ITextBufferFactory, ITextSnapshot } from 'vs/editor/common/model';
import { ITextModel, ITextBufferFactory, ITextSnapshot, ModelConstants } from 'vs/editor/common/model';
import { EditorModel, IModeSupport } from 'vs/workbench/common/editor';
import { URI } from 'vs/base/common/uri';
import { ITextEditorModel, IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
......@@ -106,12 +106,12 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd
// text buffer factory
const textBufferFactory = value as ITextBufferFactory;
if (typeof textBufferFactory.getFirstLineText === 'function') {
return textBufferFactory.getFirstLineText(100);
return textBufferFactory.getFirstLineText(ModelConstants.FIRST_LINE_DETECTION_LENGTH_LIMIT);
}
// text model
const textSnapshot = value as ITextModel;
return textSnapshot.getLineContent(1).substr(0, 100);
return textSnapshot.getLineContent(1).substr(0, ModelConstants.FIRST_LINE_DETECTION_LENGTH_LIMIT);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册