New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow text search providers to give messages with links that trigger researching. #123213
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3dff14f
Allow text search providers to give messages with links that trigger …
72dbdb8
Address feedback
cb616bc
Add trusted property to message links
0446297
Allow undefined trust state
61c077d
Document default
76437a0
Fix indentation
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import { Iterable } from 'vs/base/common/iterator'; | |
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; | ||
import { Disposable, DisposableStore, dispose } from 'vs/base/common/lifecycle'; | ||
import { parseLinkedText } from 'vs/base/common/linkedText'; | ||
import { Schemas } from 'vs/base/common/network'; | ||
import * as env from 'vs/base/common/platform'; | ||
import * as strings from 'vs/base/common/strings'; | ||
import { URI } from 'vs/base/common/uri'; | ||
|
@@ -35,6 +36,7 @@ import * as nls from 'vs/nls'; | |
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; | ||
import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; | ||
import { IMenu, IMenuService, MenuId } from 'vs/platform/actions/common/actions'; | ||
import { ICommandService } from 'vs/platform/commands/common/commands'; | ||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; | ||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; | ||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView'; | ||
|
@@ -75,6 +77,7 @@ import { createEditorFromSearchResult } from 'vs/workbench/contrib/searchEditor/ | |
import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; | ||
import { IPreferencesService, ISettingsEditorOptions } from 'vs/workbench/services/preferences/common/preferences'; | ||
import { IPatternInfo, ISearchComplete, ISearchConfiguration, ISearchConfigurationProperties, ITextQuery, SearchCompletionExitCode, SearchSortOrder, TextSearchCompleteMessageType } from 'vs/workbench/services/search/common/search'; | ||
import { TextSearchCompleteMessage } from 'vs/workbench/services/search/common/searchExtTypes'; | ||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; | ||
|
||
const $ = dom.$; | ||
|
@@ -159,6 +162,7 @@ export class SearchView extends ViewPane { | |
@IProgressService private readonly progressService: IProgressService, | ||
@INotificationService private readonly notificationService: INotificationService, | ||
@IDialogService private readonly dialogService: IDialogService, | ||
@ICommandService private readonly commandService: ICommandService, | ||
@IContextViewService private readonly contextViewService: IContextViewService, | ||
@IInstantiationService instantiationService: IInstantiationService, | ||
@IViewDescriptorService viewDescriptorService: IViewDescriptorService, | ||
|
@@ -1524,7 +1528,7 @@ export class SearchView extends ViewPane { | |
if (completed && completed.messages) { | ||
for (const message of completed.messages) { | ||
if (message.type === TextSearchCompleteMessageType.Information) { | ||
this.addMessage(message.text); | ||
this.addMessage(message); | ||
} | ||
else if (message.type === TextSearchCompleteMessageType.Warning) { | ||
warningMessage += (warningMessage ? ' - ' : '') + message.text; | ||
|
@@ -1641,8 +1645,8 @@ export class SearchView extends ViewPane { | |
} | ||
} | ||
|
||
private addMessage(message: string) { | ||
const linkedText = parseLinkedText(message); | ||
private addMessage(message: TextSearchCompleteMessage) { | ||
const linkedText = parseLinkedText(message.text); | ||
|
||
const messageBox = this.messagesElement.firstChild as HTMLDivElement; | ||
if (!messageBox) { | ||
|
@@ -1659,7 +1663,26 @@ export class SearchView extends ViewPane { | |
if (typeof node === 'string') { | ||
dom.append(span, document.createTextNode(node)); | ||
} else { | ||
const link = this.instantiationService.createInstance(Link, node); | ||
const link = this.instantiationService.createInstance(Link, node, { | ||
opener: async href => { | ||
if (!message.trusted) { return; } | ||
const parsed = URI.parse(href, true); | ||
if (parsed.scheme === Schemas.command && message.trusted) { | ||
const result = await this.commandService.executeCommand(parsed.path); | ||
JacksonKearl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if ((result as any)?.triggerSearch) { | ||
this.triggerQueryChange(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What command are you going to use this for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
} else if (parsed.scheme === Schemas.https) { | ||
this.openerService.open(parsed); | ||
} else { | ||
if (parsed.scheme === Schemas.command && !message.trusted) { | ||
this.notificationService.error(nls.localize('unable to open trust', "Unable to open command link from untrusted source: {0}", href)); | ||
} else { | ||
this.notificationService.error(nls.localize('unable to open', "Unable to open unknown link: {0}", href)); | ||
} | ||
} | ||
} | ||
}); | ||
dom.append(span, link.el); | ||
this.messageDisposables.add(link); | ||
this.messageDisposables.add(attachLinkStyler(link, this.themeService)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last parameter is optional, does the instantiation service make you pass it in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TS doesn't allow the required service injection parameters follow an optional parameter.