fix tests

This commit is contained in:
BeniBenj
2025-11-24 15:29:59 +01:00
parent 57e973501e
commit 938f270b96
2 changed files with 17 additions and 1 deletions
@@ -106,6 +106,7 @@ export class RenameSymbolProcessor extends Disposable {
if (wordRange === null) {
return undefined;
}
const endOffset = startOffset + change.originalLength;
const endPos = textModel.getPositionAt(endOffset);
const range = Range.fromPositions(startPos, endPos);
@@ -113,12 +114,14 @@ export class RenameSymbolProcessor extends Disposable {
const tokenInfo = getTokenAtPosition(textModel, startPos);
if (tokenInfo.type === StandardTokenType.Other) {
let identifier = textModel.getValueInRange(tokenInfo.range);
if (oldName === undefined) {
oldName = identifier;
} else if (oldName !== identifier) {
return undefined;
}
// We assume that the new name starts at the same position as the old name from a token range perspective.
const diff = text.length - change.originalLength;
const tokenStartPos = textModel.getOffsetAt(tokenInfo.range.getStartPosition()) - nesOffset + tokenDiff;
@@ -129,20 +132,25 @@ export class RenameSymbolProcessor extends Disposable {
} else if (newName !== identifier) {
return undefined;
}
if (position === undefined) {
position = tokenInfo.range.getStartPosition();
}
renames.push(TextEdit.replace(range, text));
tokenDiff += diff;
} else {
others.push(TextEdit.replace(range, text));
}
}
if (oldName === undefined || newName === undefined || position === undefined) {
return undefined;
}
return {
renames: { edits: renames, position, oldName, newName }, others: { edits: others }
renames: { edits: renames, position, oldName, newName },
others: { edits: others }
};
}
}
@@ -25,6 +25,7 @@ import { TextEdit } from '../../../../common/core/edits/textEdit.js';
import { BugIndicatingError } from '../../../../../base/common/errors.js';
import { PositionOffsetTransformer } from '../../../../common/core/text/positionToOffset.js';
import { InlineSuggestionsView } from '../../browser/view/inlineSuggestionsView.js';
import { IBulkEditService } from '../../../../browser/services/bulkEditService.js';
export class MockInlineCompletionsProvider implements InlineCompletionsProvider {
private returnValue: InlineCompletion[] = [];
@@ -243,6 +244,13 @@ export async function withAsyncTestCodeEditorAndInlineCompletionsModel<T>(
playSignal: async () => { },
isSoundEnabled(signal: unknown) { return false; },
} as any);
options.serviceCollection.set(IBulkEditService, {
apply: async () => { throw new Error('IBulkEditService.apply not implemented'); },
hasPreviewHandler: () => { throw new Error('IBulkEditService.hasPreviewHandler not implemented'); },
setPreviewHandler: () => { throw new Error('IBulkEditService.setPreviewHandler not implemented'); },
_serviceBrand: undefined,
});
const d = languageFeaturesService.inlineCompletionsProvider.register({ pattern: '**' }, options.provider);
disposableStore.add(d);
}