Skip to content

Commit

Permalink
feat: search service override
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Jun 9, 2023
1 parent 7c50463 commit 97f5953
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ await initialize({
})
```

Additionally, this library exposes 18 modules that include the vscode version of some services (with some glue to make it work with monaco):
Additionally, this library exposes 19 modules that include the vscode version of some services (with some glue to make it work with monaco):

- Notifications: `vscode/service-override/notifications`
- Dialogs: `vscode/service-override/dialogs`
Expand All @@ -81,6 +81,7 @@ Additionally, this library exposes 18 modules that include the vscode version of
- QuickAccess: `vscode/service-override/quickaccess`
- Output: `vscode/service-override/output`
- Terminal: `vscode/service-override/terminal`
- Search: `vscode/service-override/search`

Usage:

Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
"types": "./dist/service-override/terminal.d.ts",
"default": "./dist/service-override/terminal.js"
},
"./service-override/search": {
"types": "./dist/service-override/search.d.ts",
"default": "./dist/service-override/search.js"
},
"./workers/textMate.worker": {
"types": "./dist/workers/textMate.worker.d.ts",
"default": "./dist/workers/textMate.worker.js"
Expand Down Expand Up @@ -186,6 +190,9 @@
"service-override/terminal": [
"./dist/service-override/terminal.d.ts"
],
"service-override/search": [
"./dist/service-override/search.d.ts"
],
"workers/textMate.worker": [
"./dist/workers/textMate.worker.d.ts"
],
Expand Down
21 changes: 7 additions & 14 deletions rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ const FUNCTIONS_TO_REMOVE = new Set([

// For ActivityBar, remove unused actions/items
'fillExtraContextMenuActions',
'createGlobalActivityActionBar',

'searchWidgetContributions',
'replaceContributions'
'createGlobalActivityActionBar'
])

const PURE_OR_TO_REMOVE_FUNCTIONS = new Set([
Expand Down Expand Up @@ -111,7 +108,10 @@ const ALLOWED_WORKBENCH_CONTRIBUTIONS = new Set([
'OutputContribution',
'TerminalMainContribution',
'PreferencesActionsContribution',
'PreferencesContribution'
'PreferencesContribution',
'ReplacePreviewContentProvider',
'SearchEditorContribution',
'SearchEditorWorkingCopyEditorHandler'
])

function isCallPure (file: string, functionName: string, node: recast.types.namedTypes.CallExpression): boolean {
Expand All @@ -137,7 +137,7 @@ function isCallPure (file: string, functionName: string, node: recast.types.name
}

if (functionName === 'CommandsRegistry.registerCommand') {
if (file.includes('fileActions.contribution') || file.includes('workspaceCommands') || file.includes('search.contribution')) {
if (file.includes('fileActions.contribution') || file.includes('workspaceCommands')) {
return true
}
}
Expand Down Expand Up @@ -237,15 +237,7 @@ function isCallPure (file: string, functionName: string, node: recast.types.name
return false
}

if (functionName === 'registerViewContainer') {
if (file.includes('search.contribution')) {
return true
}
}
if (functionName === 'registerViews') {
if (file.includes('search.contribution')) {
return true
}
const firstParamCode = recast.print(args[0]!).code
if (firstParamCode.includes('WelcomeView.ID')) {
return true
Expand Down Expand Up @@ -375,6 +367,7 @@ const input = {
'service-override/quickaccess': './src/service-override/quickaccess.ts',
'service-override/output': './src/service-override/output.ts',
'service-override/terminal': './src/service-override/terminal.ts',
'service-override/search': './src/service-override/search.ts',
'workers/textMate.worker': './src/workers/textMate.worker.ts',
'workers/outputLinkComputer.worker': './src/workers/outputLinkComputer.worker.ts',
monaco: './src/monaco.ts',
Expand Down
1 change: 1 addition & 0 deletions rollup/rollup.types.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default rollup.defineConfig({
'./dist/types/src/service-override/preferences.d.ts',
'./dist/types/src/service-override/views.d.ts',
'./dist/types/src/service-override/quickaccess.d.ts',
'./dist/types/src/service-override/search.d.ts',
'./dist/types/src/service-override/output.d.ts',
'./dist/types/src/service-override/terminal.d.ts',
'./dist/types/src/workers/textMate.worker.d.ts',
Expand Down
1 change: 0 additions & 1 deletion src/service-override/quickaccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'vs/workbench/contrib/codeEditor/browser/quickaccess/gotoLineQuickAccess'
import 'vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess'
import 'vs/workbench/browser/actions/quickAccessActions'
import 'vs/workbench/contrib/quickaccess/browser/quickAccess.contribution'
import 'vs/workbench/contrib/search/browser/search.contribution'

// Remote "Configur Keybinding" from command menu
// eslint-disable-next-line dot-notation
Expand Down
20 changes: 20 additions & 0 deletions src/service-override/search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import '../vscode-services/missing-services'
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'
import { IEditorOverrideServices } from 'vs/editor/standalone/browser/standaloneServices'
import { ISearchService } from 'vs/workbench/services/search/common/search'
import { SearchService } from 'vs/workbench/services/search/common/searchService'
import { ISearchWorkbenchService, SearchWorkbenchService } from 'vs/workbench/contrib/search/browser/searchModel'
import { ISearchHistoryService, SearchHistoryService } from 'vs/workbench/contrib/search/common/searchHistoryService'
import { IReplaceService } from 'vs/workbench/contrib/search/browser/replace'
import { ReplaceService } from 'vs/workbench/contrib/search/browser/replaceService'
import 'vs/workbench/contrib/search/browser/search.contribution'
import 'vs/workbench/contrib/searchEditor/browser/searchEditor.contribution'

export default function getServiceOverride (): IEditorOverrideServices {
return {
[ISearchService.toString()]: new SyncDescriptor(SearchService),
[ISearchWorkbenchService.toString()]: new SyncDescriptor(SearchWorkbenchService),
[ISearchHistoryService.toString()]: new SyncDescriptor(SearchHistoryService),
[IReplaceService.toString()]: new SyncDescriptor(ReplaceService)
}
}
1 change: 1 addition & 0 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"src/service-override/preferences.ts",
"src/service-override/views.ts",
"src/service-override/quickaccess.ts",
"src/service-override/search.ts",
"src/service-override/output.ts",
"src/service-override/terminal.ts",
"src/workers/textMate.worker.ts",
Expand Down

0 comments on commit 97f5953

Please sign in to comment.