|
|
@ -3,12 +3,15 @@ import { configuration } from '../../configuration'; |
|
|
|
import { Commands } from '../../constants'; |
|
|
|
import type { Container } from '../../container'; |
|
|
|
import { registerCommand } from '../../system/command'; |
|
|
|
import { DidOpenAnchorNotificationType } from '../protocol'; |
|
|
|
import { WebviewWithConfigBase } from '../webviewWithConfigBase'; |
|
|
|
import type { State } from './protocol'; |
|
|
|
|
|
|
|
const anchorRegex = /.*?#(.*)/; |
|
|
|
|
|
|
|
export class SettingsWebview extends WebviewWithConfigBase<State> { |
|
|
|
private _pendingJumpToAnchor: string | undefined; |
|
|
|
|
|
|
|
constructor(container: Container) { |
|
|
|
super( |
|
|
|
container, |
|
|
@ -42,11 +45,35 @@ export class SettingsWebview extends WebviewWithConfigBase { |
|
|
|
[, anchor] = match; |
|
|
|
} |
|
|
|
|
|
|
|
return registerCommand(c, () => this.onShowCommand(anchor), this); |
|
|
|
return registerCommand(c, (...args: any[]) => this.onShowAnchorCommand(anchor, ...args), this); |
|
|
|
}), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
protected override onReady() { |
|
|
|
if (this._pendingJumpToAnchor != null) { |
|
|
|
const anchor = this._pendingJumpToAnchor; |
|
|
|
this._pendingJumpToAnchor = undefined; |
|
|
|
|
|
|
|
void this.notify(DidOpenAnchorNotificationType, { anchor: anchor, scrollBehavior: 'auto' }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private onShowAnchorCommand(anchor?: string, ...args: any[]) { |
|
|
|
if (anchor) { |
|
|
|
if (this.isReady && this.visible) { |
|
|
|
queueMicrotask( |
|
|
|
() => void this.notify(DidOpenAnchorNotificationType, { anchor: anchor, scrollBehavior: 'smooth' }), |
|
|
|
); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this._pendingJumpToAnchor = anchor; |
|
|
|
} |
|
|
|
|
|
|
|
this.onShowCommand(...args); |
|
|
|
} |
|
|
|
|
|
|
|
protected override includeBootstrap(): State { |
|
|
|
const scopes: ['user' | 'workspace', string][] = [['user', 'User']]; |
|
|
|
if (workspace.workspaceFolders?.length) { |
|
|
|