mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-21 21:48:22 +01:00
Fixed other context menus using this context
This commit is contained in:
@@ -62,7 +62,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
|
||||
import { IExtHostDecorations } from 'vs/workbench/api/common/extHostDecorations';
|
||||
import { IExtHostTask } from 'vs/workbench/api/common/extHostTask';
|
||||
import { IExtHostDebugService } from 'vs/workbench/api/common/extHostDebugService';
|
||||
import { IExtHostSearch } from 'vs/workbench/api/common/extHostSearch';
|
||||
import { ExtHostSearch } from 'vs/workbench/api/common/extHostSearch';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IURITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
@@ -123,11 +123,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
const extHostCommands = rpcProtocol.set(ExtHostContext.ExtHostCommands, accessor.get(IExtHostCommands));
|
||||
const extHostTerminalService = rpcProtocol.set(ExtHostContext.ExtHostTerminalService, accessor.get(IExtHostTerminalService));
|
||||
const extHostDebugService = rpcProtocol.set(ExtHostContext.ExtHostDebugService, accessor.get(IExtHostDebugService));
|
||||
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, accessor.get(IExtHostSearch));
|
||||
const extHostTask = rpcProtocol.set(ExtHostContext.ExtHostTask, accessor.get(IExtHostTask));
|
||||
const extHostOutputService = rpcProtocol.set(ExtHostContext.ExtHostOutputService, accessor.get(IExtHostOutputService));
|
||||
|
||||
// manually create and register addressable instances
|
||||
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, new ExtHostSearch(rpcProtocol, uriTransformer, extHostLogService, extHostCommands));
|
||||
const extHostUrls = rpcProtocol.set(ExtHostContext.ExtHostUrls, new ExtHostUrls(rpcProtocol));
|
||||
const extHostDocuments = rpcProtocol.set(ExtHostContext.ExtHostDocuments, new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors));
|
||||
const extHostDocumentContentProviders = rpcProtocol.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(rpcProtocol, extHostDocumentsAndEditors, extHostLogService));
|
||||
|
||||
@@ -14,6 +14,7 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IRawFileQuery, ISearchCompleteStats, IFileQuery, IRawTextQuery, IRawQuery, ITextQuery, IFolderQuery } from 'vs/workbench/services/search/common/search';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { TextSearchManager } from 'vs/workbench/services/search/common/textSearchManager';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
|
||||
export interface IExtHostSearch extends ExtHostSearchShape {
|
||||
registerTextSearchProvider(scheme: string, provider: vscode.TextSearchProvider): IDisposable;
|
||||
@@ -37,8 +38,21 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
constructor(
|
||||
@IExtHostRpcService private extHostRpc: IExtHostRpcService,
|
||||
@IURITransformerService protected _uriTransformer: IURITransformerService,
|
||||
@ILogService protected _logService: ILogService
|
||||
) { }
|
||||
@ILogService protected _logService: ILogService,
|
||||
commands: ExtHostCommands,
|
||||
) {
|
||||
commands.registerArgumentProcessor({
|
||||
processArgument: arg => {
|
||||
if (arg.renderableMatch !== undefined) {
|
||||
const filteredProperties = { ...arg };
|
||||
delete filteredProperties.renderableMatch;
|
||||
return filteredProperties;
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected _transformScheme(scheme: string): string {
|
||||
return this._uriTransformer.transformOutgoingScheme(scheme);
|
||||
|
||||
@@ -19,6 +19,7 @@ import { ExtHostSearch, reviveQuery } from 'vs/workbench/api/common/extHostSearc
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { NativeTextSearchManager } from 'vs/workbench/services/search/node/textSearchManager';
|
||||
import { TextSearchManager } from 'vs/workbench/services/search/common/textSearchManager';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
|
||||
export class NativeExtHostSearch extends ExtHostSearch {
|
||||
|
||||
@@ -32,8 +33,9 @@ export class NativeExtHostSearch extends ExtHostSearch {
|
||||
@IExtHostInitDataService initData: IExtHostInitDataService,
|
||||
@IURITransformerService _uriTransformer: IURITransformerService,
|
||||
@ILogService _logService: ILogService,
|
||||
commands: ExtHostCommands,
|
||||
) {
|
||||
super(extHostRpc, _uriTransformer, _logService);
|
||||
super(extHostRpc, _uriTransformer, _logService, commands);
|
||||
|
||||
if (initData.remote.isRemote && initData.remote.authority) {
|
||||
this._registerEHSearchProviders();
|
||||
|
||||
@@ -15,7 +15,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { getSelectionKeyboardEvent, WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
|
||||
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
|
||||
import { IFileMatchContext, IFolderMatchWithResourceContext, IRenderableMatchContext, SearchView } from 'vs/workbench/contrib/search/browser/searchView';
|
||||
import * as Constants from 'vs/workbench/contrib/search/common/constants';
|
||||
import { IReplaceService } from 'vs/workbench/contrib/search/common/replace';
|
||||
import { FolderMatch, FileMatch, FolderMatchWithResource, Match, RenderableMatch, searchMatchComparer, SearchResult } from 'vs/workbench/contrib/search/common/searchModel';
|
||||
@@ -776,7 +776,8 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
|
||||
}
|
||||
}
|
||||
|
||||
export const copyPathCommand: ICommandHandler = async (accessor, fileMatch: FileMatch | FolderMatchWithResource | undefined) => {
|
||||
export const copyPathCommand: ICommandHandler = async (accessor, fileMatchArg: IFileMatchContext | IFolderMatchWithResourceContext | undefined) => {
|
||||
let fileMatch = fileMatchArg?.renderableMatch;
|
||||
if (!fileMatch) {
|
||||
const selection = getSelectedRow(accessor);
|
||||
if (!(selection instanceof FileMatch || selection instanceof FolderMatchWithResource)) {
|
||||
@@ -852,7 +853,8 @@ function folderMatchToString(folderMatch: FolderMatchWithResource | FolderMatch,
|
||||
}
|
||||
|
||||
const maxClipboardMatches = 1e4;
|
||||
export const copyMatchCommand: ICommandHandler = async (accessor, match: RenderableMatch | undefined) => {
|
||||
export const copyMatchCommand: ICommandHandler = async (accessor, matchArg: IRenderableMatchContext | undefined) => {
|
||||
let match = matchArg?.renderableMatch;
|
||||
if (!match) {
|
||||
const selection = getSelectedRow(accessor);
|
||||
if (!selection) {
|
||||
|
||||
@@ -98,6 +98,7 @@ export interface IMatchContext {
|
||||
uri: URI;
|
||||
/** location of where the matched text is inside the file */
|
||||
matchRange: Range;
|
||||
renderableMatch: Match;
|
||||
}
|
||||
|
||||
export interface IFileMatchContext {
|
||||
@@ -107,6 +108,7 @@ export interface IFileMatchContext {
|
||||
uri: URI;
|
||||
/** matches for this particular file */
|
||||
matches: IMatchContext[];
|
||||
renderableMatch: FileMatch;
|
||||
}
|
||||
|
||||
export interface IFolderMatchContext {
|
||||
@@ -118,9 +120,15 @@ export interface IFolderMatchContext {
|
||||
matches: IFileMatchContext[];
|
||||
/** resource that might be associate with this match */
|
||||
resource: URI | null;
|
||||
renderableMatch: FolderMatch;
|
||||
}
|
||||
|
||||
export type IRenderableMatchContext = IMatchContext | IFileMatchContext | IFolderMatchContext;
|
||||
export interface IFolderMatchWithResourceContext extends IFolderMatchContext {
|
||||
resource: URI;
|
||||
renderableMatch: FolderMatchWithResource;
|
||||
}
|
||||
|
||||
export type IRenderableMatchContext = (IMatchContext | IFileMatchContext | IFolderMatchContext);
|
||||
|
||||
function toMatchContext(match: Match): IMatchContext {
|
||||
return {
|
||||
@@ -129,7 +137,8 @@ function toMatchContext(match: Match): IMatchContext {
|
||||
uri: URI.parse(match.parent().id()),
|
||||
matchedText: match.fullMatchText(),
|
||||
replacementText: match.replaceString,
|
||||
matchRange: match.range()
|
||||
matchRange: match.range(),
|
||||
renderableMatch: match
|
||||
} as IMatchContext;
|
||||
}
|
||||
|
||||
@@ -137,7 +146,8 @@ function toFileMatchContext(fileMatch: FileMatch): IFileMatchContext {
|
||||
return {
|
||||
matchingKind: 'fileMatch',
|
||||
uri: URI.parse(fileMatch.id()),
|
||||
matches: fileMatch.matches().map(toMatchContext)
|
||||
matches: fileMatch.matches().map(toMatchContext),
|
||||
renderableMatch: fileMatch
|
||||
} as IFileMatchContext;
|
||||
}
|
||||
|
||||
@@ -145,7 +155,8 @@ function toFolderMatchContext<T extends IFolderMatchContext>(folderMatch: Folder
|
||||
return {
|
||||
matchingKind: 'folderMatch',
|
||||
matches: folderMatch.matches().map(toFileMatchContext),
|
||||
id: folderMatch.id()
|
||||
id: folderMatch.id(),
|
||||
renderableMatch: folderMatch
|
||||
} as T;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,6 +157,10 @@ export class Match {
|
||||
getMatchString(): string {
|
||||
return this._oneLinePreviewText.substring(this._rangeInPreviewText.startColumn - 1, this._rangeInPreviewText.endColumn - 1);
|
||||
}
|
||||
|
||||
toJSON(): object {
|
||||
return {}; // We send an IRenderableMatchContext to the extensions
|
||||
}
|
||||
}
|
||||
|
||||
export class FileMatch extends Disposable implements IFileMatch {
|
||||
@@ -444,6 +448,10 @@ export class FileMatch extends Disposable implements IFileMatch {
|
||||
this._onDispose.fire();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
toJSON(): object {
|
||||
return {}; // We send an IRenderableMatchContext to the extensions
|
||||
}
|
||||
}
|
||||
|
||||
export interface IChangeEvent {
|
||||
@@ -634,6 +642,10 @@ export class FolderMatch extends Disposable {
|
||||
this._onDispose.fire();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
toJSON(): object {
|
||||
return {}; // We send an IRenderableMatchContext to the extensions
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ import { mock } from 'vs/base/test/common/mock';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
import { TextSearchManager } from 'vs/workbench/services/search/common/textSearchManager';
|
||||
import { NativeTextSearchManager } from 'vs/workbench/services/search/node/textSearchManager';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
|
||||
let rpcProtocol: TestRPCProtocol;
|
||||
let extHostSearch: NativeExtHostSearch;
|
||||
@@ -146,7 +147,8 @@ suite('ExtHostSearch', () => {
|
||||
rpcProtocol,
|
||||
new class extends mock<IExtHostInitDataService>() { remote = { isRemote: false, authority: undefined, connectionData: null }; },
|
||||
new URITransformerService(null),
|
||||
logService
|
||||
logService,
|
||||
new ExtHostCommands(rpcProtocol, new NullLogService())
|
||||
);
|
||||
this._pfs = mockPFS as any;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user