mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
fix tests
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user