mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode 3c6f6af7347d38e87bc6406024e8dcf9e9bce229 (#8962)
* Merge from vscode 3c6f6af7347d38e87bc6406024e8dcf9e9bce229 * skip failing tests * update mac build image
This commit is contained in:
committed by
Karl Burtram
parent
0eaee18dc4
commit
fefe1454de
@@ -72,11 +72,12 @@ function spacesDiff(a: string, aLength: number, b: string, bLength: number, resu
|
||||
|
||||
if (spacesDiff > 0 && 0 <= bSpacesCnt - 1 && bSpacesCnt - 1 < a.length && bSpacesCnt < b.length) {
|
||||
if (b.charCodeAt(bSpacesCnt) !== CharCode.Space && a.charCodeAt(bSpacesCnt - 1) === CharCode.Space) {
|
||||
// This looks like an alignment desire: e.g.
|
||||
// const a = b + c,
|
||||
// d = b - c;
|
||||
|
||||
result.looksLikeAlignment = true;
|
||||
if (a.charCodeAt(a.length - 1) === CharCode.Comma) {
|
||||
// This looks like an alignment desire: e.g.
|
||||
// const a = b + c,
|
||||
// d = b - c;
|
||||
result.looksLikeAlignment = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -1947,6 +1947,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
private _matchBracket(position: Position): [Range, Range] | null {
|
||||
const lineNumber = position.lineNumber;
|
||||
const lineTokens = this._getLineTokens(lineNumber);
|
||||
const tokenCount = lineTokens.getCount();
|
||||
const lineText = this._buffer.getLineContent(lineNumber);
|
||||
|
||||
const tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
|
||||
@@ -1959,6 +1960,15 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
if (currentModeBrackets && !ignoreBracketsInToken(lineTokens.getStandardTokenType(tokenIndex))) {
|
||||
// limit search to not go before `maxBracketLength`
|
||||
let searchStartOffset = Math.max(0, position.column - 1 - currentModeBrackets.maxBracketLength);
|
||||
for (let i = tokenIndex - 1; i >= 0; i--) {
|
||||
const tokenEndOffset = lineTokens.getEndOffset(i);
|
||||
if (tokenEndOffset <= searchStartOffset) {
|
||||
break;
|
||||
}
|
||||
if (ignoreBracketsInToken(lineTokens.getStandardTokenType(i))) {
|
||||
searchStartOffset = tokenEndOffset;
|
||||
}
|
||||
}
|
||||
// limit search to not go after `maxBracketLength`
|
||||
const searchEndOffset = Math.min(lineText.length, position.column - 1 + currentModeBrackets.maxBracketLength);
|
||||
|
||||
@@ -1998,7 +2008,16 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
if (prevModeBrackets && !ignoreBracketsInToken(lineTokens.getStandardTokenType(prevTokenIndex))) {
|
||||
// limit search in case previous token is very large, there's no need to go beyond `maxBracketLength`
|
||||
const searchStartOffset = Math.max(0, position.column - 1 - prevModeBrackets.maxBracketLength);
|
||||
const searchEndOffset = Math.min(lineText.length, position.column - 1 + prevModeBrackets.maxBracketLength);
|
||||
let searchEndOffset = Math.min(lineText.length, position.column - 1 + prevModeBrackets.maxBracketLength);
|
||||
for (let i = prevTokenIndex + 1; i < tokenCount; i++) {
|
||||
const tokenStartOffset = lineTokens.getStartOffset(i);
|
||||
if (tokenStartOffset >= searchEndOffset) {
|
||||
break;
|
||||
}
|
||||
if (ignoreBracketsInToken(lineTokens.getStandardTokenType(i))) {
|
||||
searchEndOffset = tokenStartOffset;
|
||||
}
|
||||
}
|
||||
const foundBracket = BracketsUtils.findPrevBracketInRange(prevModeBrackets.reversedRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
|
||||
|
||||
// check that we didn't hit a bracket too far away from position
|
||||
|
||||
@@ -804,7 +804,7 @@ export class TokensStore2 {
|
||||
aIndex++;
|
||||
}
|
||||
|
||||
const aMetadata = aTokens.getMetadata(aIndex - 1 > 0 ? aIndex - 1 : aIndex);
|
||||
const aMetadata = aTokens.getMetadata(Math.min(Math.max(0, aIndex - 1), aLen - 1));
|
||||
const languageId = TokenMetadata.getLanguageId(aMetadata);
|
||||
const tokenType = TokenMetadata.getTokenType(aMetadata);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user