jiebi/CodeConvo huggingface dataset:
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { XtermLinkMatcherHandler } from 'vs/workbench/contrib/terminal/browser/links/terminalLinkManager'; import { TerminalBaseLinkProvider } from 'vs/workbench/contrib/terminal/browser/links/terminalBaseLinkProvider'; <del> import { normalize } from 'vs/base/common/path'; </del> <ins> import { normalize, isAbsolute } from 'vs/base/common/path'; </ins> import { convertLinkRangeToBuffer, getXtermLineContent } from 'vs/workbench/contrib/terminal/browser/links/terminalLinkHelpers'; import { isWindows } from 'vs/base/common/platform'; <ins> import { IFileService } from 'vs/platform/files/common/files'; import { URI } from 'vs/base/common/uri'; import { Schemas } from 'vs/base/common/network'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; </ins> const MAX_LENGTH = 2000;
@IQuickInputService private readonly _quickInputService: IQuickInputService, @IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService, @ISearchService private readonly _searchService: ISearchService, <del> @IEditorService private readonly _editorService: IEditorService </del> <ins> @IEditorService private readonly _editorService: IEditorService, @IFileService private readonly _fileService: IFileService, @IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService </ins> ) { super(); }
} private async _activate(link: string) { <del> // Normalize the link and remove any leading ./ or ../ since quick access doesn't understand // that format </del> <ins> // Remove file:/// and any leading ./ or ../ since quick access doesn't understand that format link = link.replace(/^file:///?/, ''); </ins> link = normalize(link).replace(/^(.+[/])+/, ''); // Remove `:in` from the end which is how Ruby outputs stack traces
}); const sanitizedLink = link.replace(/:d+(:d+)?$/, ''); <del> const results = await this._searchService.fileSearch( this._fileQueryBuilder.file(this._workspaceContextService.getWorkspace().folders, { // Remove optional :row:col from the link as openEditor supports it filePattern: sanitizedLink, maxResults: 2 }) ); // If there was exactly one match, open it if (results.results.length === 1) { </del> <ins> let exactMatch = await this._getExactMatch(sanitizedLink, link); if (exactMatch) { // If there was exactly one match, open it </ins> const match = link.match(/:(d+)?(:(d+))?$/); const startLineNumber = match?.[1]; const startColumn = match?.[3]; await this._editorService.openEditor({ <del> resource: results.results[0].resource, </del> <ins> resource: exactMatch, </ins> options: { pinned: true, revealIfOpened: true,
}); return; } // Fallback to searching quick access <del> this._quickInputService.quickAccess.show(link); </del> <ins> return this._quickInputService.quickAccess.show(link); } private async _getExactMatch(sanitizedLink: string, link: string): Promise<URI | undefined> { let exactResource: URI | undefined; if (isAbsolute(sanitizedLink)) { const scheme = this._environmentService.remoteAuthority ? Schemas.vscodeRemote : Schemas.file; const resource = URI.from({ scheme, path: sanitizedLink }); const fileStat = await this._fileService.resolve(resource); if (fileStat.isFile) { exactResource = resource; } } if (!exactResource) { const results = await this._searchService.fileSearch( this._fileQueryBuilder.file(this._workspaceContextService.getWorkspace().folders, { // Remove optional :row:col from the link as openEditor supports it filePattern: sanitizedLink, maxResults: 2 }) ); if (results.results.length === 1) { exactResource = results.results[0].resource; } } return exactResource; </ins> } }
await configurationService.setUserConfiguration('terminal', { integrated: { wordSeparators: ' ' } }); await assertLink('', []); }); <ins> test('should support file scheme links', async () => { await configurationService.setUserConfiguration('terminal', { integrated: { wordSeparators: ' ' } }); await assertLink('file:///C:/users/test/file.txt ', [{ range: [[1, 1], [30, 1]], text: 'file:///C:/users/test/file.txt' }]); await assertLink('file:///C:/users/test/file.txt:1:10 ', [{ range: [[1, 1], [35, 1]], text: 'file:///C:/users/test/file.txt:1:10' }]); }); </ins> });
} if (e.element instanceof InstructionBreakpoint) { const disassemblyView = await this.editorService.openEditor(DisassemblyViewInput.instance); <del> (disassemblyView as DisassemblyView).goToAddress(e.element.instructionReference); </del> <ins> // Focus on double click (disassemblyView as DisassemblyView).goToAddress(e.element.instructionReference, e.browserEvent instanceof MouseEvent && e.browserEvent.detail === 2); </ins> } if (e.browserEvent instanceof MouseEvent && e.browserEvent.detail === 2 && e.element instanceof FunctionBreakpoint && e.element !== this.inputBoxData?.breakpoint) { // double click
const bottomElement = Math.floor((this._disassembledInstructions.scrollTop + this._disassembledInstructions.renderHeight) / this.fontInfo.lineHeight); if (index > topElement && index < bottomElement) { // Inside the viewport, don't do anything here <del> return; </del> } else if (index <= topElement && index > topElement - 5) { // Not too far from top, review it at the top <del> return this._disassembledInstructions.reveal(index, 0); </del> <ins> this._disassembledInstructions.reveal(index, 0); </ins> } else if (index >= bottomElement && index < bottomElement + 5) { // Not too far from bottom, review it at the bottom <del> return this._disassembledInstructions.reveal(index, 1); </del> <ins> this._disassembledInstructions.reveal(index, 1); </ins> } else { // Far from the current viewport, reveal it <del> return this._disassembledInstructions.reveal(index, 0.5); </del> <ins> this._disassembledInstructions.reveal(index, 0.5); } if (focus) { this._disassembledInstructions.domFocus(); this._disassembledInstructions.setFocus([index]); </ins> } } else if (this._debugService.state === State.Stopped) { // Address is not provided or not in the table currently, clear the table // and reload if we are in the state where we can load disassembly. <del> return this.reloadDisassembly(address); </del> <ins> this.reloadDisassembly(address); </ins> } }
this.loadDisassembledInstructions(targetAddress, -DisassemblyView.NUM_INSTRUCTIONS_TO_LOAD, DisassemblyView.NUM_INSTRUCTIONS_TO_LOAD * 2).then(() => { // on load, set the target instruction in the middle of the page. if (this._disassembledInstructions!.length > 0) { <del> this._disassembledInstructions!.reveal(Math.floor(this._disassembledInstructions!.length / 2), 0.5); </del> <ins> const targetIndex = Math.floor(this._disassembledInstructions!.length / 2); this._disassembledInstructions!.reveal(targetIndex, 0.5); // Always focus the target address on reload, or arrow key navigation would look terrible this._disassembledInstructions!.domFocus(); this._disassembledInstructions!.setFocus([targetIndex]); </ins> } }); }
// Without formatting we still need to support the separator // as provided in options (https://github.com/microsoft/vscode/issues/130019) if (!formatting && options.separator) { <del> switch (options.separator) { case paths.win32.sep: return paths.win32.normalize(label); case paths.posix.sep: return paths.posix.normalize(label); } </del> <ins> return label.replace(sepRegexp, options.separator); </ins> } return label;
assert.strictEqual(generated, label); }); }); <ins> test('relative label with explicit path separator', () => { let generated = labelService.getUriLabel(URI.parse('myscheme://myauthority/some/folder/test.txt'), { relative: true, separator: '/' }); assert.strictEqual(generated, 'some/folder/test.txt'); generated = labelService.getUriLabel(URI.parse('myscheme://myauthority/some/folder/test.txt'), { relative: true, separator: '' }); assert.strictEqual(generated, 'somefoldertest.txt'); }); </ins> });
import { FindReplaceState, FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/findState'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; <del> import { contrastBorder, editorFindMatch, editorFindMatchBorder, editorFindMatchHighlight, editorFindMatchHighlightBorder, editorFindRangeHighlight, editorFindRangeHighlightBorder, editorWidgetBackground, editorWidgetBorder, editorWidgetResizeBorder, errorForeground, inputActiveOptionBorder, inputActiveOptionBackground, inputActiveOptionForeground, inputBackground, inputBorder, inputForeground, inputValidationErrorBackground, inputValidationErrorBorder, inputValidationErrorForeground, inputValidationInfoBackground, inputValidationInfoBorder, inputValidationInfoForeground, inputValidationWarningBackground, inputValidationWarningBorder, inputValidationWarningForeground, widgetShadow, editorWidgetForeground, focusBorder } from 'vs/platform/theme/common/colorRegistry'; </del> <ins> import { contrastBorder, editorFindMatch, editorFindMatchBorder, editorFindMatchHighlight, editorFindMatchHighlightBorder, editorFindRangeHighlight, editorFindRangeHighlightBorder, editorWidgetBackground, editorWidgetBorder, editorWidgetResizeBorder, errorForeground, inputActiveOptionBorder, inputActiveOptionBackground, inputActiveOptionForeground, inputBackground, inputBorder, inputForeground, inputValidationErrorBackground, inputValidationErrorBorder, inputValidationErrorForeground, inputValidationInfoBackground, inputValidationInfoBorder, inputValidationInfoForeground, inputValidationWarningBackground, inputValidationWarningBorder, inputValidationWarningForeground, widgetShadow, editorWidgetForeground, focusBorder, toolbarHoverBackground } from 'vs/platform/theme/common/colorRegistry'; </ins> import { IColorTheme, IThemeService, registerThemingParticipant, ThemeIcon } from 'vs/platform/theme/common/themeService'; import { ContextScopedFindInput, ContextScopedReplaceInput } from 'vs/platform/browser/contextScopedHistoryWidget'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
} } <ins> // Action bars const toolbarHoverBackgroundColor = theme.getColor(toolbarHoverBackground); if (toolbarHoverBackgroundColor) { collector.addRule(` .monaco-editor .find-widget .button:not(.disabled):hover, .monaco-editor .find-widget .codicon-find-selection:hover { background-color: ${toolbarHoverBackgroundColor} !important; } `); } </ins> // This rule is used to override the outline color for synthetic-focus find input. const focusOutline = theme.getColor(focusBorder); if (focusOutline) {
this.container.classList.toggle('height-constrained', size.height <= 600); this.container.classList.toggle('width-constrained', size.width <= 400); this.container.classList.toggle('width-semi-constrained', size.width <= 800); <ins> this.categoriesPageScrollbar?.scanDomNode(); this.detailsPageScrollbar?.scanDomNode(); this.detailsScrollbar?.scanDomNode(); </ins> } private updateCategoryProgress() {
weight: weight, kbExpr: EditorContextKeys.textInputFocus, primary: KeyMod.CtrlCmd | KeyCode.Space, <del> mac: { primary: KeyMod.WinCtrl | KeyCode.Space } </del> <ins> secondary: [KeyMod.CtrlCmd | KeyCode.KEY_I], mac: { primary: KeyMod.WinCtrl | KeyCode.Space, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_I] } </ins> }, menuOpts: [{ menuId: suggestWidgetStatusbarMenu,
return new vscode.FoldingRange(start, end, kind); } <del> private static readonly foldEndPairCharacters = ['}', ']', ')', '`']; </del> <ins> private static readonly foldEndPairCharacters = ['}', ']', ')', '`', '>']; </ins> private adjustFoldingEnd(range: vscode.Range, document: vscode.TextDocument) { // workaround for #47240
autoplayPolicy: 'user-gesture-required', // Enable experimental css highlight api https://chromestatus.com/feature/5436441440026624 // Refs https://github.com/microsoft/vscode/issues/140098 <del> enableBlinkFeatures: 'HighlightAPI', </del> <ins> enableBlinkFeatures: 'HighlightAPI, KeyboardAccessibleTooltip', </ins> ...overrides?.webPreferences, sandbox: true },
render(container: HTMLElement): void { // file/folder const label = this._labels.create(container); <ins> this._disposables.add(label.onDidRender(() => { container.title = container.children[0]?.ariaLabel ?? ''; })); </ins> label.setFile(this.element.uri, { hidePath: true, hideIcon: this.element.kind === FileKind.FOLDER || !this.options.showFileIcons,
renderElement(node: ITreeNode<OutlineElement, FuzzyScore>, _index: number, template: DocumentSymbolTemplate): void { const { element } = node; const extraClasses = ['nowrap']; <ins> const title = localize('title.template', "{0} ({1})", element.symbol.name, symbolKindNames[element.symbol.kind]); </ins> const options: IIconLabelValueOptions = { matches: createMatches(node.filterData), labelEscapeNewLines: true, extraClasses, <del> title: localize('title.template', "{0} ({1})", element.symbol.name, symbolKindNames[element.symbol.kind]) </del> <ins> title </ins> }; <ins> template.container.title = title; </ins> if (this._configurationService.getValue(OutlineConfigKeys.icons)) { // add styles for the icons template.iconClass.className = '';
hoverPreparation = toDispose; }; const mouseOverDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_OVER, onMouseOver, true); <ins> const onFocus = () => { if (hoverPreparation) { return; } const target: IHoverDelegateTarget = { targetElements: [htmlElement], dispose: () => { } }; const toDispose: DisposableStore = new DisposableStore(); const onBlur = () => hideHover(true, true); toDispose.add(dom.addDisposableListener(htmlElement, dom.EventType.BLUR, onBlur, true)); toDispose.add(triggerShowHover(hoverDelegate.delay, false, target)); hoverPreparation = toDispose; }; const focusDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.FOCUS, onFocus, true); </ins> const hover: ICustomHover = { show: focus => { hideHover(false, true); // terminate a ongoing mouse over preparation
]); }); }); <ins> test('Do not reuse cache from previous session (#132516)', async function () { const provider = new MockInlineCompletionsProvider(); await withAsyncTestCodeEditorAndInlineCompletionsModel('', { fakeClock: true, provider, inlineSuggest: { enabled: true } }, async ({ editor, editorViewModel, model, context }) => { model.setActive(true); context.keyboardType('hellon'); context.cursorLeft(); provider.setReturnValue({ text: 'helloworld', range: new Range(1, 1, 1, 6) }, 1000); await timeout(2000); assert.deepStrictEqual(provider.getAndClearCallHistory(), [ { position: '(1,6)', text: 'hellon', triggerKind: 0, } ]); provider.setReturnValue({ text: 'helloworld', range: new Range(2, 1, 2, 6) }, 1000); context.cursorDown(); context.keyboardType('hello'); await timeout(100); context.cursorLeft(); // Cause the ghost text to update context.cursorRight(); await timeout(2000); assert.deepStrictEqual(provider.getAndClearCallHistory(), [ { position: '(2,6)', text: 'hellonhello', triggerKind: 0, } ]); assert.deepStrictEqual(context.getAndClearViewStates(), [ '', 'hello[world]n', 'hellon', 'hellonhello[world]', ]); }); }); </ins> }); async function withAsyncTestCodeEditorAndInlineCompletionsModel<T>(
import { timeout } from 'vs/base/common/async'; import { CancellationToken } from 'vs/base/common/cancellation'; import { Disposable } from 'vs/base/common/lifecycle'; <del> import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands'; </del> <ins> import { CoreEditingCommands, CoreNavigationCommands } from 'vs/editor/browser/controller/coreCommands'; </ins> import { Position } from 'vs/editor/common/core/position'; import { ITextModel } from 'vs/editor/common/model'; import { InlineCompletionsProvider, InlineCompletion, InlineCompletionContext } from 'vs/editor/common/modes';
this.editor.trigger('keyboard', 'type', { text }); } <ins> public cursorUp(): void { CoreNavigationCommands.CursorUp.runEditorCommand(null, this.editor, null); } public cursorRight(): void { CoreNavigationCommands.CursorRight.runEditorCommand(null, this.editor, null); } public cursorLeft(): void { CoreNavigationCommands.CursorLeft.runEditorCommand(null, this.editor, null); } public cursorDown(): void { CoreNavigationCommands.CursorDown.runEditorCommand(null, this.editor, null); } public cursorLineEnd(): void { CoreNavigationCommands.CursorLineEnd.runEditorCommand(null, this.editor, null); } </ins> public leftDelete(): void { CoreEditingCommands.DeleteLeft.runEditorCommand(null, this.editor, null); }
<ins> /*--------------------------------------------------------------------------------------------- *  Copyright (c) Microsoft Corporation. All rights reserved. *  Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; import 'mocha'; import { ExtensionContext, extensions } from 'vscode'; suite('vscode API - globalState / workspaceState', () => { let extensionContext: ExtensionContext; suiteSetup(async () => { // Trigger extension activation and grab the context as some tests depend on it await extensions.getExtension('vscode.vscode-api-tests')?.activate(); extensionContext = (global as any).testExtensionContext; }); test.only('state', async () => { for (const state of [extensionContext.globalState, extensionContext.workspaceState]) { let keys = state.keys(); assert.strictEqual(keys.length, 0); let res = state.get('state.test.get', 'default'); assert.strictEqual(res, 'default'); await state.update('state.test.get', 'testvalue'); keys = state.keys(); assert.strictEqual(keys.length, 1); assert.strictEqual(keys[0], 'state.test.get'); res = state.get('state.test.get', 'default'); assert.strictEqual(res, 'testvalue'); await state.update('state.test.get', undefined); keys = state.keys(); assert.strictEqual(keys.length, 0); res = state.get('state.test.get', 'default'); assert.strictEqual(res, 'default'); } }); }); </ins>
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; import { IDisposable } from 'vs/base/common/lifecycle'; import { IExtensionIdWithVersion, IExtensionsStorageSyncService } from 'vs/platform/userDataSync/common/extensionsStorageSync'; <ins> import { ILogService } from 'vs/platform/log/common/log'; </ins> @extHostNamedCustomer(MainContext.MainThreadStorage) export class MainThreadStorage implements MainThreadStorageShape {
this._storageListener = this._storageService.onDidChangeValue(e => { const shared = e.scope === StorageScope.GLOBAL; if (shared && this._sharedStorageKeysToWatch.has(e.key)) { <del> try { this._proxy.$acceptValue(shared, e.key, this._getValue(shared, e.key)); } catch (error) { // ignore parsing errors that can happen } </del> <ins> this._proxy.$acceptValue(shared, e.key, this._getValue(shared, e.key)); </ins> } }); }
this._storageListener.dispose(); } <del> $getValue<T>(shared: boolean, key: string): Promise<T | undefined> { </del> <ins> async $getValue<T>(shared: boolean, key: string): Promise<T | undefined> { </ins> if (shared) { this._sharedStorageKeysToWatch.set(key, true); } <del> try { return Promise.resolve(this._getValue<T>(shared, key)); } catch (error) { return Promise.reject(error); } </del> <ins> return this._getValue<T>(shared, key); </ins> } private _getValue<T>(shared: boolean, key: string): T | undefined { const jsonValue = this._storageService.get(key, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE); <del> if (!jsonValue) { return undefined; </del> <ins> if (jsonValue) { try { return JSON.parse(jsonValue); } catch (error) { // Do not fail this call but log it for diagnostics // https://github.com/microsoft/vscode/issues/132777 this._logService.error(`[mainThreadStorage] unexpected error parsing storage contents (key: ${key}, shared: ${shared}): ${error}`); } </ins> } <del> return JSON.parse(jsonValue); </del> <ins> return undefined; </ins> } <del> $setValue(shared: boolean, key: string, value: object): Promise<void> { let jsonValue: string; try { jsonValue = JSON.stringify(value); // Extension state is synced separately through extensions this._storageService.store(key, jsonValue, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE, StorageTarget.MACHINE); } catch (err) { return Promise.reject(err); } return Promise.resolve(undefined); </del> <ins> async $setValue(shared: boolean, key: string, value: object): Promise<void> { this._storageService.store(key, JSON.stringify(value), shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE, StorageTarget.MACHINE /* Extension state is synced separately through extensions */); </ins> } $registerExtensionStorageKeysToSync(extension: IExtensionIdWithVersion, keys: string[]): void {
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; import { revive } from 'vs/base/common/marshalling'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; <ins> import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; </ins> @extHostNamedCustomer(MainContext.MainThreadCommands) export class MainThreadCommands implements MainThreadCommandsShape {
} } <del> async $executeCommand<T>(id: string, args: any[], retry: boolean): Promise<T | undefined> { </del> <ins> async $executeCommand<T>(id: string, args: any[] | SerializableObjectWithBuffers<any[]>, retry: boolean): Promise<T | undefined> { if (args instanceof SerializableObjectWithBuffers) { args = args.value; } </ins> for (let i = 0; i < args.length; i++) { args[i] = revive(args[i]); }
export interface MainThreadCommandsShape extends IDisposable { $registerCommand(id: string): void; $unregisterCommand(id: string): void; <del> $executeCommand<T>(id: string, args: any[], retry: boolean): Promise<T | undefined>; </del> <ins> $executeCommand<T>(id: string, args: any[] | SerializableObjectWithBuffers<any[]>, retry: boolean): Promise<T | undefined>; </ins> $getCommands(): Promise<string[]>; }
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService'; import { ISelection } from 'vs/editor/common/core/selection'; import { TestItemImpl } from 'vs/workbench/api/common/extHostTestingPrivateApi'; <ins> import { VSBuffer } from 'vs/base/common/buffer'; import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier'; </ins> interface CommandHandler { callback: Function;
return extHostTypeConverter.location.from(value); } else if (extHostTypes.NotebookRange.isNotebookRange(value)) { return extHostTypeConverter.NotebookRange.from(value); <ins> } else if (value instanceof ArrayBuffer) { hasBuffers = true; return VSBuffer.wrap(new Uint8Array(value)); } else if (value instanceof Uint8Array) { hasBuffers = true; return VSBuffer.wrap(value); </ins> } if (!Array.isArray(value)) { return value;
}); try { <del> const result = await this._proxy.$executeCommand<T>(id, toArgs, retry); </del> <ins> const result = await this._proxy.$executeCommand<T>(id, hasBuffers ? new SerializableObjectWithBuffers(toArgs) : toArgs, retry); </ins> return revive<any>(result); } catch (e) { // Rerun the command when it wasn't known, had arguments, and when retry
constructor() { super({ id: 'editor.gotoPreviousFold', <del> label: nls.localize('gotoPreviousFold.label', "Go to Previous Fold"), alias: 'Go to Previous Fold', </del> <ins> label: nls.localize('gotoPreviousFold.label', "Go to Previous Folding Range"), alias: 'Go to Previous Folding Range', </ins> precondition: CONTEXT_FOLDING_ENABLED, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus,
constructor() { super({ id: 'editor.gotoNextFold', <del> label: nls.localize('gotoNextFold.label', "Go to Next Fold"), alias: 'Go to Next Fold', </del> <ins> label: nls.localize('gotoNextFold.label', "Go to Next Folding Range"), alias: 'Go to Next Folding Range', </ins> precondition: CONTEXT_FOLDING_ENABLED, kbOpts: { kbExpr: EditorContextKeys.editorTextFocus,