mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 4c9161a3f125f5a788aafa73a4ecfcb27dcfc319 (#9143)
* Merge from vscode 4c9161a3f125f5a788aafa73a4ecfcb27dcfc319 * minor spacing fix
This commit is contained in:
@@ -105,8 +105,6 @@ suite('suggest, word distance', function () {
|
||||
}
|
||||
|
||||
test('Suggest locality bonus can boost current word #90515', function () {
|
||||
this.skip();
|
||||
|
||||
const pos = { lineNumber: 2, column: 2 };
|
||||
const d1 = distance.distance(pos, createSuggestItem('a', 1, pos).completion);
|
||||
const d2 = distance.distance(pos, createSuggestItem('aa', 1, pos).completion);
|
||||
|
||||
@@ -35,14 +35,23 @@ export abstract class WordDistance {
|
||||
return WordDistance.None;
|
||||
}
|
||||
|
||||
const ranges = await new BracketSelectionRangeProvider().provideSelectionRanges(model, [position]);
|
||||
if (!ranges || ranges.length === 0 || ranges[0].length === 0) {
|
||||
const [ranges] = await new BracketSelectionRangeProvider().provideSelectionRanges(model, [position]);
|
||||
if (ranges.length === 0) {
|
||||
return WordDistance.None;
|
||||
}
|
||||
const wordRanges = await service.computeWordRanges(model.uri, ranges[0][0].range);
|
||||
|
||||
const wordRanges = await service.computeWordRanges(model.uri, ranges[0].range);
|
||||
if (!wordRanges) {
|
||||
return WordDistance.None;
|
||||
}
|
||||
|
||||
// remove current word
|
||||
const wordUntilPos = model.getWordUntilPosition(position);
|
||||
delete wordRanges[wordUntilPos.word];
|
||||
|
||||
return new class extends WordDistance {
|
||||
distance(anchor: IPosition, suggestion: CompletionItem) {
|
||||
if (!wordRanges || !position.equals(editor.getPosition())) {
|
||||
if (!position.equals(editor.getPosition())) {
|
||||
return 0;
|
||||
}
|
||||
if (suggestion.kind === CompletionItemKind.Keyword) {
|
||||
@@ -56,7 +65,7 @@ export abstract class WordDistance {
|
||||
let idx = binarySearch(wordLines, Range.fromPositions(anchor), Range.compareRangesUsingStarts);
|
||||
let bestWordRange = idx >= 0 ? wordLines[idx] : wordLines[Math.max(0, ~idx - 1)];
|
||||
let blockDistance = ranges.length;
|
||||
for (const range of ranges[0]) {
|
||||
for (const range of ranges) {
|
||||
if (!Range.containsRange(range.range, bestWordRange)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user