提交 24b9056e 编写于 作者: A Alex Dima

Fix lgtm issues

上级 d99486b6
......@@ -65,7 +65,6 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
const selectionIsEmpty = e.selections[0].isEmpty();
if (this._selectionIsEmpty !== selectionIsEmpty) {
this._selectionIsEmpty = selectionIsEmpty;
hasChanged = true;
return true;
}
......
......@@ -63,7 +63,6 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
const selectionIsEmpty = e.selections[0].isEmpty();
if (this._selectionIsEmpty !== selectionIsEmpty) {
this._selectionIsEmpty = selectionIsEmpty;
hasChanged = true;
return true;
}
......
......@@ -1954,7 +1954,7 @@ export class EditorOptionsValidator {
} else if (<any>renderWhitespace === false) {
renderWhitespace = 'none';
}
renderWhitespace = _stringSet<'none' | 'boundary' | 'all'>(opts.renderWhitespace, defaults.renderWhitespace, ['none', 'boundary', 'all']);
renderWhitespace = _stringSet<'none' | 'boundary' | 'all'>(renderWhitespace, defaults.renderWhitespace, ['none', 'boundary', 'all']);
}
let renderLineHighlight = opts.renderLineHighlight;
......@@ -1965,7 +1965,7 @@ export class EditorOptionsValidator {
} else if (<any>renderLineHighlight === false) {
renderLineHighlight = 'none';
}
renderLineHighlight = _stringSet<'none' | 'gutter' | 'line' | 'all'>(opts.renderLineHighlight, defaults.renderLineHighlight, ['none', 'gutter', 'line', 'all']);
renderLineHighlight = _stringSet<'none' | 'gutter' | 'line' | 'all'>(renderLineHighlight, defaults.renderLineHighlight, ['none', 'gutter', 'line', 'all']);
}
let mouseWheelScrollSensitivity = _float(opts.mouseWheelScrollSensitivity, defaults.scrollbar.mouseWheelScrollSensitivity);
......
......@@ -159,7 +159,7 @@ export class TypeOperations {
action = expectedIndentAction.action;
indentation = expectedIndentAction.indentation;
} else if (lineNumber > 1) {
let lastLineNumber = lineNumber - 1;
let lastLineNumber: number;
for (lastLineNumber = lineNumber - 1; lastLineNumber >= 1; lastLineNumber--) {
let lineText = model.getLineContent(lastLineNumber);
let nonWhitespaceIdx = strings.lastNonWhitespaceIndex(lineText);
......
......@@ -732,6 +732,12 @@ export interface ITextModel {
*/
findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null;
/**
* Flush all tokenization state.
* @internal
*/
flushTokens(): void;
/**
* Force tokenization information for `lineNumber` to be accurate.
* @internal
......
......@@ -464,11 +464,9 @@ export function nodeAcceptEdit(node: IntervalNode, start: number, end: number, t
const deltaColumn = (insertingCnt - deletingCnt);
if (!startDone) {
node.start = Math.max(0, nodeStart + deltaColumn);
startDone = true;
}
if (!endDone) {
node.end = Math.max(0, nodeEnd + deltaColumn);
endDone = true;
}
if (node.start > node.end) {
......
......@@ -1840,6 +1840,16 @@ export class TextModel extends Disposable implements model.ITextModel {
}
}
public flushTokens(): void {
this._resetTokenizationState();
this.emitModelTokensChangedEvent({
ranges: [{
fromLineNumber: 1,
toLineNumber: this.getLineCount()
}]
});
}
public forceTokenization(lineNumber: number): void {
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
throw new Error('Illegal value for lineNumber');
......
......@@ -154,7 +154,7 @@ class ModelLineTokens {
let fromTokenIndex = LineTokens.findIndexInTokensArray(tokens, chIndex);
if (fromTokenIndex > 0) {
const fromTokenStartOffset = (fromTokenIndex > 0 ? tokens[(fromTokenIndex - 1) << 1] : 0);
const fromTokenStartOffset = tokens[(fromTokenIndex - 1) << 1];
if (fromTokenStartOffset === chIndex) {
fromTokenIndex--;
}
......
......@@ -60,10 +60,6 @@ function getWordAtPosFast(column: number, wordDefinition: RegExp, text: string,
let pos = column - 1 - textOffset;
let start = text.lastIndexOf(' ', pos - 1) + 1;
let end = text.indexOf(' ', pos);
if (end === -1) {
end = text.length;
}
wordDefinition.lastIndex = start;
let match: RegExpMatchArray | null;
......
......@@ -332,7 +332,7 @@ export class LanguageConfigurationRegistryImpl {
private getPrecedingValidLine(model: IVirtualModel, lineNumber: number, indentRulesSupport: IndentRulesSupport) {
let languageID = model.getLanguageIdAtPosition(lineNumber, 0);
if (lineNumber > 1) {
let lastLineNumber = lineNumber - 1;
let lastLineNumber: number;
let resultLineNumber = -1;
for (lastLineNumber = lineNumber - 1; lastLineNumber >= 1; lastLineNumber--) {
......
......@@ -92,8 +92,7 @@ export class ViewModelDecorations implements IDisposable {
}
public getDecorationsViewportData(viewRange: Range): IDecorationsViewportData {
let cacheIsValid = true;
cacheIsValid = cacheIsValid && (this._cachedModelDecorationsResolver !== null);
let cacheIsValid = (this._cachedModelDecorationsResolver !== null);
cacheIsValid = cacheIsValid && (viewRange.equalsRange(this._cachedModelDecorationsResolverViewRange));
if (!cacheIsValid) {
this._cachedModelDecorationsResolver = this._getDecorationsViewportData(viewRange);
......
......@@ -219,7 +219,6 @@ function compileAction(lexer: monarchCommon.ILexerMin, ruleName: string, action:
else if (action.token || action.token === '') {
if (typeof (action.token) !== 'string') {
throw monarchCommon.createError(lexer, 'a \'token\' attribute must be of type string, in rule: ' + ruleName);
return { token: '' };
}
else {
// only copy specific typed fields (only happens once during compile Lexer)
......@@ -321,7 +320,6 @@ function compileAction(lexer: monarchCommon.ILexerMin, ruleName: string, action:
}
else {
throw monarchCommon.createError(lexer, 'an action must be a string, an object with a \'token\' or \'cases\' attribute, or an array of actions; in rule: ' + ruleName);
return '';
}
}
......
......@@ -115,7 +115,7 @@ export class IntegrityServiceImpl implements IIntegrityService {
return Promise.all(asyncResults).then<IntegrityTestResult>((allResults) => {
let isPure = true;
for (let i = 0, len = allResults.length; isPure && i < len; i++) {
for (let i = 0, len = allResults.length; i < len; i++) {
if (!allResults[i].isPure) {
isPure = false;
break;
......
......@@ -800,7 +800,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
for (let i = 0, len = kbCombos.length; i < len; i++) {
const kbCombo = kbCombos[i];
// find out the priority of this scan code for this key code
let colPriority = '-';
let colPriority: string;
const scanCodeCombos = this._scanCodeKeyCodeMapper.lookupKeyCodeCombo(kbCombo);
if (scanCodeCombos.length === 1) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册