repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
libro | github_2023 | weavefox | typescript | VirtualDocument.closeForeign | closeForeign(document: VirtualDocument): void {
this._foreignDocumentClosed.fire({
foreignDocument: document,
parentHost: this,
});
// remove it from foreign documents list
this.foreignDocuments.delete(document.virtualId);
// and delete the documents within it
document.closeAllForeig... | /**
* Close a foreign document and disconnect all associated signals
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L793-L806 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.closeAllForeignDocuments | closeAllForeignDocuments(): void {
for (const document of this.foreignDocuments.values()) {
this.closeForeign(document);
}
} | /**
* Close all foreign documents.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L811-L815 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.closeExpiredDocuments | closeExpiredDocuments(): void {
for (const document of this.unusedDocuments.values()) {
document.remainingLifetime -= 1;
if (document.remainingLifetime <= 0) {
document.dispose();
}
}
} | /**
* Close all expired documents.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L820-L827 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.transformSourceToEditor | transformSourceToEditor(pos: ISourcePosition): IEditorPosition {
const sourceLine = this.sourceLines.get(pos.line)!;
const editorLine = sourceLine.editorLine;
const editorShift = sourceLine.editorShift;
return {
// only shift column in the line beginning the virtual document (first list of the edi... | /**
* Transform the position of the source to the editor
* position.
*
* @param pos - position in the source document
* @return position in the editor.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L836-L847 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.transformVirtualToEditor | transformVirtualToEditor(virtualPosition: IVirtualPosition): IEditorPosition | null {
const sourcePosition = this.transformVirtualToSource(virtualPosition);
if (!sourcePosition) {
return null;
}
return this.transformSourceToEditor(sourcePosition);
} | /**
* Transform the position in the virtual document to the
* editor position.
* Can be null because some lines are added as padding/anchors
* to the virtual document and those do not exist in the source document
* and thus they are absent in the editor.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L856-L862 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.transformVirtualToSource | transformVirtualToSource(position: IVirtualPosition): ISourcePosition | null {
const line = this.virtualLines.get(position.line)!.sourceLine;
if (line === null) {
return null;
}
return {
ch: position.ch,
line: line,
} as ISourcePosition;
} | /**
* Transform the position in the virtual document to the source.
* Can be null because some lines are added as padding/anchors
* to the virtual document and those do not exist in the source document.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L869-L878 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.getEditorAtVirtualLine | getEditorAtVirtualLine(pos: IVirtualPosition): Document.IEditor {
let line = pos.line;
// tolerate overshot by one (the hanging blank line at the end)
if (!this.virtualLines.has(line)) {
line -= 1;
}
return this.virtualLines.get(line)!.editor;
} | /**
* Get the corresponding editor of the virtual line.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L883-L890 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.getEditorAtSourceLine | getEditorAtSourceLine(pos: ISourcePosition): Document.IEditor {
return this.sourceLines.get(pos.line)!.editor;
} | /**
* Get the corresponding editor of the source line
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L895-L897 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.maybeEmitChanged | maybeEmitChanged(): void {
if (this.value !== this.previousValue) {
this._changed.fire(this);
}
this.previousValue = this.value;
for (const document of this.foreignDocuments.values()) {
document.maybeEmitChanged();
}
} | /**
* Recursively emits changed signal from the document or any descendant foreign document.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L902-L910 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.remainingLifetime | protected get remainingLifetime(): number {
if (!this.parent) {
return Infinity;
}
return this._remainingLifetime;
} | /**
* When this counter goes down to 0, the document will be destroyed and the associated connection will be closed;
* This is meant to reduce the number of open connections when a a foreign code snippet was removed from the document.
*
* Note: top level virtual documents are currently immortal (unless kill... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L920-L925 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.chooseForeignDocument | protected chooseForeignDocument(extractor: IForeignCodeExtractor): VirtualDocument {
let foreignDocument: VirtualDocument;
// if not standalone, try to append to existing document
const foreignExists = this.foreignDocuments.has(extractor.language);
if (!extractor.standalone && foreignExists) {
for... | /**
* Get the foreign document that can be opened with the input extractor.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L955-L971 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.openForeign | protected openForeign(
language: language,
standalone: boolean,
fileExtension: string,
): VirtualDocument {
const document = this.factory({
...this.options,
parent: this,
standalone: standalone,
fileExtension: fileExtension,
language: language,
});
const context: ... | /**
* Create a foreign document from input language and file extension.
*
* @param language - the required language
* @param standalone - the document type is supported natively by LSP?
* @param fileExtension - File extension.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L980-L1004 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.forwardClosedSignal | protected forwardClosedSignal(context: Document.IForeignContext) {
this._foreignDocumentClosed.fire(context);
} | /**
* Forward the closed signal from the foreign document to the host document's
* signal
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1010-L1012 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument.forwardOpenedSignal | protected forwardOpenedSignal(context: Document.IForeignContext) {
this._foreignDocumentOpened.fire(context);
} | /**
* Forward the opened signal from the foreign document to the host document's
* signal
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1018-L1020 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument._updateBeganSlot | protected _updateBeganSlot(): void {
this._editorToSourceLineNew = new Map();
} | /**
* Slot of the `updateBegan` signal.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1025-L1027 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument._blockAddedSlot | protected _blockAddedSlot(blockData: IBlockAddedInfo): void {
this._editorToSourceLineNew.set(
blockData.block.ceEditor,
blockData.virtualDocument.lastSourceLine,
);
} | /**
* Slot of the `blockAdded` signal.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1032-L1037 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | VirtualDocument._updateFinishedSlot | protected _updateFinishedSlot(): void {
this._editorToSourceLine = this._editorToSourceLineNew;
} | /**
* Slot of the `updateFinished` signal.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1042-L1044 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.constructor | constructor(protected virtualDocument: VirtualDocument) {
this._blockAdded = new Emitter<IBlockAddedInfo>();
this._documentUpdated = new Emitter<VirtualDocument>();
this._updateBegan = new Emitter<Document.ICodeBlockOptions[]>();
this._updateFinished = new Emitter<Document.ICodeBlockOptions[]>();
th... | // eslint-disable-next-line @typescript-eslint/parameter-properties, @typescript-eslint/no-parameter-properties | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1101-L1107 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.updateDone | get updateDone(): Promise<void> {
return this._updateDone;
} | /**
* Promise resolved when the updating process finishes.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1112-L1114 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.blockAdded | get blockAdded(): Event<IBlockAddedInfo> {
return this._blockAdded.event;
} | /**
* Signal emitted when a code block is added to the document.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1125-L1127 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.documentUpdated | get documentUpdated(): Event<VirtualDocument> {
return this._documentUpdated.event;
} | /**
* Signal emitted by the editor that triggered the update,
* providing the root document of the updated documents.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1133-L1135 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.updateBegan | get updateBegan(): Event<Document.ICodeBlockOptions[]> {
return this._updateBegan.event;
} | /**
* Signal emitted when the update is started
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1140-L1142 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.updateFinished | get updateFinished(): Event<Document.ICodeBlockOptions[]> {
return this._updateFinished.event;
} | /**
* Signal emitted when the update is finished
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1147-L1149 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.dispose | dispose(): void {
if (this._isDisposed) {
return;
}
this._isDisposed = true;
} | /**
* Dispose the class
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1154-L1159 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.withUpdateLock | async withUpdateLock(fn: () => void): Promise<void> {
await untilReady(() => this._canUpdate(), 12, 10).then(() => {
try {
this._updateLock = true;
fn();
} catch (ex) {
console.error(ex);
} finally {
this._updateLock = false;
}
return;
});
} | /**
* Execute provided callback within an update-locked context, which guarantees that:
* - the previous updates must have finished before the callback call, and
* - no update will happen when executing the callback
* @param fn - the callback to execute in update lock
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1167-L1179 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager.updateDocuments | async updateDocuments(blocks: Document.ICodeBlockOptions[]): Promise<void> {
const update = new Promise<void>((resolve, reject) => {
// defer the update by up to 50 ms (10 retrials * 5 ms break),
// awaiting for the previous update to complete.
untilReady(() => this._canUpdate(), 10, 5)
.t... | /**
* Update all the virtual documents, emit documents updated with root document if succeeded,
* and resolve a void promise. The promise does not contain the text value of the root document,
* as to avoid an easy trap of ignoring the changes in the virtual documents.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1186-L1229 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager._onUpdated | protected _onUpdated(rootDocument: VirtualDocument) {
try {
rootDocument.closeExpiredDocuments();
} catch (e) {
console.warn('Failed to close expired documents');
}
} | /**
* Once all the foreign documents were refreshed, the unused documents (and their connections)
* should be terminated if their lifetime has expired.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1259-L1265 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | UpdateManager._canUpdate | protected _canUpdate() {
return !this.isDisposed && !this._isUpdateInProgress && !this._updateLock;
} | /**
* Check if the document can be updated.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/virtual/document.ts#L1270-L1272 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | registerServerCapability | function registerServerCapability(
serverCapabilities: ServerCapabilities,
registration: Registration,
): ServerCapabilities | null {
const serverCapabilitiesCopy = JSON.parse(
JSON.stringify(serverCapabilities),
) as IFlexibleServerCapabilities;
const { method, registerOptions } = registration;
const p... | /**
* Register the capabilities with the server capabilities provider
*
* @param serverCapabilities - server capabilities provider.
* @param registration - capabilities to be registered.
* @return - the new server capabilities provider
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/server-capability-registration.ts#L29-L53 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | unregisterServerCapability | function unregisterServerCapability(
serverCapabilities: ServerCapabilities,
unregistration: Unregistration,
): ServerCapabilities {
const serverCapabilitiesCopy = JSON.parse(
JSON.stringify(serverCapabilities),
) as IFlexibleServerCapabilities;
const { method } = unregistration;
const providerName = me... | /**
* Unregister the capabilities with the server capabilities provider
*
* @param serverCapabilities - server capabilities provider.
* @param registration - capabilities to be unregistered.
* @return - the new server capabilities provider
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/server-capability-registration.ts#L62-L75 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.isConnected | get isConnected(): boolean {
return this._isConnected;
} | /**
* Is the language server is connected?
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L35-L37 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.isInitialized | get isInitialized(): boolean {
return this._isInitialized;
} | /**
* Is the language server is initialized?
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L42-L44 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.isReady | get isReady() {
return this._isConnected && this._isInitialized;
} | /**
* Is the language server is connected and initialized?
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L49-L51 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.onDisposed | get onDisposed(): Event<void> {
return this._disposed.event;
} | /**
* A signal emitted when the connection is disposed.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L56-L58 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.isDisposed | get isDisposed(): boolean {
return this._isDisposed;
} | /**
* Check if the connection is disposed
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L63-L65 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.connect | connect(socket: WebSocket): void {
this.socket = socket;
listen({
webSocket: this.socket,
logger: new ConsoleLogger(),
onConnection: (connection: MessageConnection) => {
connection.listen();
this._isConnected = true;
this.connection = connection;
this.sendIniti... | /**
* Initialize a connection over a web socket that speaks the LSP protocol
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L70-L122 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.close | close() {
if (this.connection) {
this.connection.dispose();
}
this.openedUris.clear();
this.socket.close();
} | /**
* Close the connection
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L127-L133 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.sendInitialize | sendInitialize() {
if (!this._isConnected) {
return;
}
this.openedUris.clear();
const message: protocol.InitializeParams = this.initializeParams();
this.connection
.sendRequest<protocol.InitializeResult>('initialize', message)
.then(
(params) => {
this.onServer... | /**
* The initialize request telling the server which options the client supports
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L138-L159 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.sendOpen | sendOpen(documentInfo: IDocumentInfo) {
const textDocumentMessage: protocol.DidOpenTextDocumentParams = {
textDocument: {
uri: documentInfo.uri,
languageId: documentInfo.languageId,
text: documentInfo.text,
version: documentInfo.version,
} as protocol.TextDocumentItem,
... | /**
* Inform the server that the document was opened
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L164-L178 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.sendChange | sendChange(documentInfo: IDocumentInfo) {
if (!this.isReady) {
return;
}
if (!this.openedUris.get(documentInfo.uri)) {
this.sendOpen(documentInfo);
return;
}
const textDocumentChange: protocol.DidChangeTextDocumentParams = {
textDocument: {
uri: documentInfo.uri,
... | /**
* Sends the full text of the document to the server
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L183-L202 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.sendSaved | sendSaved(documentInfo: IDocumentInfo) {
if (!this.isReady) {
return;
}
const textDocumentChange: protocol.DidSaveTextDocumentParams = {
textDocument: {
uri: documentInfo.uri,
version: documentInfo.version,
} as protocol.VersionedTextDocumentIdentifier,
text: documen... | /**
* Send save notification to the server.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L207-L222 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.sendConfigurationChange | sendConfigurationChange(settings: protocol.DidChangeConfigurationParams) {
if (!this.isReady) {
return;
}
this.connection
.sendNotification('workspace/didChangeConfiguration', settings)
.catch(console.error);
} | /**
* Send configuration change to the server.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L227-L235 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.dispose | dispose(): void {
if (this._isDisposed) {
return;
}
this._isDisposed = true;
this._disposables.forEach((disposable) => {
disposable.dispose();
});
this._disposed.fire();
} | /**
* Dispose the connection.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L240-L249 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.onServerInitialized | protected onServerInitialized(params: protocol.InitializeResult): void {
this._isInitialized = true;
this.serverCapabilities = params.capabilities;
this.connection.sendNotification('initialized', {}).catch(console.error);
this.connection
.sendNotification('workspace/didChangeConfiguration', {
... | /**
* Callback called when the server is initialized.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L290-L299 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LspWsConnection.initializeParams | protected initializeParams(): protocol.InitializeParams {
return {
capabilities: {} as protocol.ClientCapabilities,
processId: null,
rootUri: this._rootUri,
workspaceFolders: null,
};
} | /**
* Initialization parameters to be sent to the language server.
* Subclasses should override this when adding more features.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/ws-connection/ws-connection.ts#L305-L312 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | convertBundle | function convertBundle(bundle: IMimeBundle): PartialJSONObject {
const map: PartialJSONObject = Object.create(null);
for (const mimeType in bundle) {
map[mimeType] = extract(bundle, mimeType);
}
return map;
} | /**
* Convert a mime bundle to mime data.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-output/src/output-utils.ts#L78-L84 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.constructor | constructor(
@inject(IRenderMimeRegistryOptions) options: IRenderMimeRegistryOptions,
@inject(MarkdownParser) markdownParser: MarkdownParser,
) {
// Parse the options.
// this.translator = options.translator ?? nullTranslator;
this.resolver = options.resolver ?? null;
this.linkHandler = option... | /**
* Construct a new rendermime.
*
* @param options - The options for initializing the instance.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L43-L60 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.mimeTypes | get mimeTypes(): readonly string[] {
return this._types || (this._types = sortedTypes(this._ranks));
} | /**
* The ordered list of mimeTypes.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L93-L95 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.preferredMimeType | preferredMimeType(
model: BaseOutputView,
// safe: 'ensure' | 'prefer' | 'any' = 'ensure',
): string | undefined {
// // Try to find a safe factory first, if preferred.
// if (safe === 'ensure' || safe === 'prefer') {
// for (const mt of this.mimeTypes) {
// if (mt in bundle && this._fac... | /**
* Find the preferred mime type for a mime bundle.
*
* @param bundle - The bundle of mime data.
*
* @param safe - How to consider safe/unsafe factories. If 'ensure',
* it will only consider safe factories. If 'any', any factory will be
* considered. If 'prefer', unsafe factories will be cons... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L133-L172 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.createRenderer | createRenderer(
mimeType: string,
model: BaseOutputView, // model: BaseOutputModel,
// host: HTMLElement,
): IRendererFactory {
const renderMimes = this.getSortedRenderMimes(model);
for (const renderMime of renderMimes) {
for (const mt of renderMime.mimeTypes) {
if (mimeType === mt) ... | /**
* Create a renderer for a mime type.
*
* @param mimeType - The mime type of interest.
*
* @returns A new renderer for the given mime type.
*
* @throws An error if no factory exists for the mime type.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L183-L212 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.getFactory | getFactory(mimeType: string): IRendererFactory | undefined {
return this._factories[mimeType];
} | /**
* Get the renderer factory registered for a mime type.
*
* @param mimeType - The mime type of interest.
*
* @returns The factory for the mime type, or `undefined`.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L221-L223 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.addFactory | addFactory(factory: IRendererFactory, _rank?: number): void {
let rank = _rank;
if (rank === undefined) {
rank = factory.defaultRank;
if (rank === undefined) {
rank = 100;
}
}
for (const mt of factory.mimeTypes) {
this._factories[mt] = factory;
this._ranks[mt] = { r... | /**
* Add a renderer factory to the rendermime.
*
* @param factory - The renderer factory of interest.
*
* @param _rank - The rank of the renderer. A lower rank indicates
* a higher priority for rendering. If not given, the rank will
* defer to the `defaultRank` of the factory. If no `defaultR... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L239-L252 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.removeMimeType | removeMimeType(mimeType: string): void {
delete this._factories[mimeType];
delete this._ranks[mimeType];
this._types = null;
} | /**
* Remove a mime type.
*
* @param mimeType - The mime type of interest.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L259-L263 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.getRank | getRank(mimeType: string): number | undefined {
const rank = this._ranks[mimeType];
return rank && rank.rank;
} | /**
* Get the rank for a given mime type.
*
* @param mimeType - The mime type of interest.
*
* @returns The rank of the mime type or undefined.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L272-L275 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | RenderMimeRegistry.setRank | setRank(mimeType: string, rank: number): void {
if (!this._ranks[mimeType]) {
return;
}
const id = this._id++;
this._ranks[mimeType] = { rank, id };
this._types = null;
} | /**
* Set the rank of a given mime type.
*
* @param mimeType - The mime type of interest.
*
* @param rank - The new rank to assign.
*
* #### Notes
* This is a no-op if the mime type is not registered.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-registry.ts#L287-L294 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | convertBundle | function convertBundle(bundle: IMimeBundle): PartialJSONObject {
const map: PartialJSONObject = Object.create(null);
for (const mimeType in bundle) {
map[mimeType] = extract(bundle, mimeType);
}
return map;
} | /**
* Convert a mime bundle to mime data.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-utils.ts#L63-L69 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | pushColoredChunk | function pushColoredChunk(
chunk: string,
fg: number | number[],
bg: number | number[],
bold: boolean,
underline: boolean,
inverse: boolean,
out: string[],
): void {
let _fg = fg;
let _bg = bg;
if (chunk) {
const classes = [];
const styles = [];
if (bold && typeof _fg === 'number' && 0 ... | /**
* Create HTML tags for a string with given foreground, background etc. and
* add them to the `out` array.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-utils.ts#L94-L155 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | getExtendedColors | function getExtendedColors(numbers: number[]): number | number[] {
let r;
let g;
let b;
const n = numbers.shift();
if (n === 2 && numbers.length >= 3) {
// 24-bit RGB
r = numbers.shift()!;
g = numbers.shift()!;
b = numbers.shift()!;
if ([r, g, b].some((c) => c < 0 || 255 < c)) {
thro... | /**
* Convert ANSI extended colors to R/G/B triple.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-utils.ts#L160-L199 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | handleAttr | async function handleAttr(
node: HTMLElement,
name: 'src' | 'href',
resolver: IResolver,
): Promise<void> {
const source = node.getAttribute(name) || '';
const isLocal = resolver.isLocal ? resolver.isLocal(source) : URL.isLocal(source);
if (!source || !isLocal) {
return;
}
try {
const urlPath = ... | /**
* Handle a node with a `src` or `href` attribute.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-utils.ts#L551-L576 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | handleAnchor | function handleAnchor(
anchor: HTMLAnchorElement,
resolver: IResolver,
linkHandler: ILinkHandler | null,
): Promise<void> {
// Get the link path without the location prepended.
// (e.g. "./foo.md#Header 1" vs "http://localhost:8888/foo.md#Header 1")
let href = anchor.getAttribute('href') || '';
const isLo... | /**
* Handle an anchor node.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-rendermime/src/rendermime-utils.ts#L581-L628 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeCellSearchProviderContribution.getInitialQuery | getInitialQuery = (cell: CellView): string => {
if (cell instanceof LibroCodeCellView) {
const selection = cell.editor?.getSelectionValue();
// if there are newlines, just return empty string
return selection?.search(/\r?\n|\r/g) === -1 ? selection : '';
}
return '';
} | /**
* Get an initial query value if applicable so that it can be entered
* into the search box as an initial query
*
* @returns Initial value used to populate the search box.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-cell-search-provider-contribution.ts | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeCellSearchProvider.constructor | constructor(
@inject(CodeEditorSearchHighlighterFactory)
highlighterFactory: CodeEditorSearchHighlighterFactory,
@inject(GenericSearchProviderFactory)
genericSearchProviderFactory: GenericSearchProviderFactory,
@inject(CodeCellSearchOption) option: CodeCellSearchOption,
) {
super(highlighterFa... | /**
* Constructor
*
* @param cell Cell widget
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-cell-search-provider.ts#L24-L52 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeCellSearchProvider.matchesCount | override get matchesCount(): number {
if (!this.isActive) {
return 0;
}
return (
super.matchesCount +
this.outputsProvider.reduce(
(sum, provider) => sum + (provider.matchesCount ?? 0),
0,
)
);
} | /**
* Number of matches in the cell.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-cell-search-provider.ts#L57-L69 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeCellSearchProvider.clearHighlight | override async clearHighlight(): Promise<void> {
await super.clearHighlight();
await Promise.all(
this.outputsProvider.map((provider) => provider.clearHighlight()),
);
} | /**
* Clear currently highlighted match.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-cell-search-provider.ts#L74-L79 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeCellSearchProvider.dispose | override dispose(): void {
if (this.isDisposed) {
return;
}
super.dispose();
this.outputsProvider.map((provider) => {
provider.dispose();
});
this.outputsProvider.length = 0;
} | /**
* Dispose the search provider
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-cell-search-provider.ts#L84-L93 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeCellSearchProvider.highlightNext | override async highlightNext(): Promise<SearchMatch | undefined> {
if (this.matchesCount === 0 || !this.isActive) {
this.currentIndex = undefined;
} else {
if (this.currentProviderIndex === -1) {
const match = await super.highlightNext();
if (match) {
this.currentIndex = th... | /**
* Highlight the next match.
*
* @returns The next match if there is one.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-cell-search-provider.ts#L100-L135 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeCellSearchProvider.highlightPrevious | override async highlightPrevious(): Promise<SearchMatch | undefined> {
if (this.matchesCount === 0 || !this.isActive) {
this.currentIndex = undefined;
} else {
if (this.currentIndex === undefined) {
this.currentProviderIndex = this.outputsProvider.length - 1;
}
while (this.curre... | /**
* Highlight the previous match.
*
* @returns The previous match if there is one.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-cell-search-provider.ts#L142-L177 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeCellSearchProvider.startQuery | override async startQuery(
query: RegExp | null,
filters?: SearchFilters,
): Promise<void> {
await super.startQuery(query, filters);
// Search outputs
if (filters?.searchCellOutput) {
await Promise.all(
this.outputsProvider.map((provider) => {
provider.startQuery(query, thi... | /**
* Initialize the search using the provided options. Should update the UI to highlight
* all matches and "select" the first match.
*
* @param query A RegExp to be use to perform the search
* @param filters Filter parameters to pass to provider
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-cell-search-provider.ts#L186-L199 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.constructor | constructor(
@inject(CodeEditorSearchHighlighterFactory)
highlighterFactory: CodeEditorSearchHighlighterFactory,
cell: LibroCodeCellView,
) {
this.cell = cell;
this.highlighterFactory = highlighterFactory;
this.currentIndex = undefined;
this.stateChangedEmitter = new Emitter<void>();
t... | /**
* Constructor
*
* @param cell Cell widget
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L48-L78 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.getInitialQuery | getInitialQuery(): string {
const selection = this.cell?.editor?.getSelectionValue();
// if there are newlines, just return empty string
return selection?.search(/\r?\n|\r/g) === -1 ? selection : '';
} | /**
* Get an initial query value if applicable so that it can be entered
* into the search box as an initial query
*
* @returns Initial value used to populate the search box.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L86-L90 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.stateChanged | get stateChanged(): Event<void> {
return this.stateChangedEmitter.event;
} | /**
* Changed signal to be emitted when search matches change.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L105-L107 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.currentMatchIndex | get currentMatchIndex(): number | undefined {
return this.isActive ? this.currentIndex : undefined;
} | /**
* Current match index
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L112-L114 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.isActive | get isActive(): boolean {
return this._isActive;
} | /**
* Whether the cell search is active.
*
* This is used when applying search only on selected cells.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L121-L123 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.isDisposed | get isDisposed(): boolean {
return this._isDisposed;
} | /**
* Whether the search provider is disposed or not.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L128-L130 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.matchesCount | get matchesCount(): number {
return this.isActive ? this.editorHighlighter.matches.length : 0;
} | /**
* Number of matches in the cell.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L135-L137 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.clearHighlight | clearHighlight(): Promise<void> {
this.currentIndex = undefined;
this.editorHighlighter.clearHighlight();
return Promise.resolve();
} | /**
* Clear currently highlighted match
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L146-L151 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.dispose | dispose(): void {
if (this.isDisposed) {
return;
}
this.toDispose.dispose();
this._isDisposed = true;
if (this.isActive) {
this.endQuery().catch((reason) => {
console.error(`Failed to end search query on cells.`, reason);
});
}
} | /**
* Dispose the search provider
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L156-L167 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.setIsActive | async setIsActive(v: boolean): Promise<void> {
if (this.isActive !== v) {
this._isActive = v;
}
if (this.isActive) {
if (this.query !== null) {
await this.startQuery(this.query, this.filters);
}
} else {
await this.endQuery();
}
} | /**
* Set `isActive` status.
*
* #### Notes
* It will start or end the search
*
* @param v New value
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L177-L188 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.startQuery | async startQuery(query: RegExp | null, filters?: SearchFilters): Promise<void> {
this.query = query;
this.filters = filters;
if (this.cell.hasInputHidden) {
return;
}
await this.setEditor();
// Search input
await this.updateMatches();
} | /**
* Initialize the search using the provided options. Should update the UI
* to highlight all matches and "select" the first match.
*
* @param query A RegExp to be use to perform the search
* @param filters Filter parameters to pass to provider
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L197-L206 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.endQuery | async endQuery(): Promise<void> {
this.currentIndex = undefined;
this.query = null;
await this.editorHighlighter.endQuery();
} | /**
* Stop the search and clean any UI elements.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L211-L215 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.highlightNext | async highlightNext(): Promise<SearchMatch | undefined> {
if (this.matchesCount === 0 || !this.isActive) {
this.currentIndex = undefined;
} else {
if (this.lastReplacementPosition) {
this.cell.editor?.setCursorPosition(this.lastReplacementPosition);
this.lastReplacementPosition = nul... | /**
* Highlight the next match.
*
* @returns The next match if there is one.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L222-L243 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.highlightPrevious | async highlightPrevious(): Promise<SearchMatch | undefined> {
if (this.matchesCount === 0 || !this.isActive) {
this.currentIndex = undefined;
} else {
// This starts from the cursor position
const match = await this.editorHighlighter.highlightPrevious();
if (match) {
this.current... | /**
* Highlight the previous match.
*
* @returns The previous match if there is one.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L250-L265 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.replaceCurrentMatch | replaceCurrentMatch(newText: string): Promise<boolean> {
if (!this.isActive) {
return Promise.resolve(false);
}
let occurred = false;
if (
this.currentIndex !== undefined &&
this.currentIndex < this.editorHighlighter.matches.length
) {
const editor = this.cell.editor;
... | /**
* Replace the currently selected match with the provided text.
*
* If no match is selected, it won't do anything.
*
* @param newText The replacement text.
* @returns Whether a replace occurred.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L275-L309 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.replaceAllMatches | replaceAllMatches = (newText: string): Promise<boolean> => {
if (!this.isActive) {
return Promise.resolve(false);
}
const occurred = this.editorHighlighter.matches.length > 0;
// const src = this.cell.model.value;
// let lastEnd = 0;
// const finalSrc = this.cmHandler.matches.reduce((agg,... | /**
* Replace all matches in the cell source with the provided text
*
* @param newText The replacement text.
* @returns Whether a replace occurred.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorCellSearchProvider.getCurrentMatch | protected getCurrentMatch(): SearchMatch | undefined {
if (this.currentIndex === undefined) {
return undefined;
} else {
let match: SearchMatch | undefined = undefined;
if (this.currentIndex < this.editorHighlighter.matches.length) {
match = this.editorHighlighter.matches[this.currentI... | /**
* Get the current match if it exists.
*
* @returns The current match
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/code-editor-cell-search-provider.ts#L355-L365 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchHighlighter.matches | get matches(): SearchMatch[] {
return this._matches;
} | /**
* The list of matches
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/search-highlighter.ts#L27-L29 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchHighlighter.constructor | constructor() {
this._matches = new Array<SearchMatch>();
this.currentIndex = undefined;
} | /**
* Constructor
*
* @param editor The CodeMirror editor
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/search-highlighter.ts#L50-L53 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchHighlighter.clearHighlight | clearHighlight(): void {
this.currentIndex = undefined;
this._highlightCurrentMatch();
} | /**
* Clear all highlighted matches
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/search-highlighter.ts#L58-L61 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchHighlighter.endQuery | endQuery(): Promise<void> {
this._currentIndex = undefined;
this._matches = [];
if (this.editor) {
this.editor.highlightMatches([], undefined);
const selection = this.editor.getSelection();
const start = this.editor.getOffsetAt(selection.start);
const end = this.editor.getOffsetAt... | /**
* Clear the highlighted matches.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/search-highlighter.ts#L66-L86 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchHighlighter.highlightNext | highlightNext(): Promise<SearchMatch | undefined> {
this.currentIndex = this._findNext(false);
this._highlightCurrentMatch();
return Promise.resolve(
this.currentIndex !== undefined ? this._matches[this.currentIndex] : undefined,
);
} | /**
* Highlight the next match
*
* @returns The next match if available
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/search-highlighter.ts#L93-L99 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchHighlighter.highlightPrevious | highlightPrevious(): Promise<SearchMatch | undefined> {
this.currentIndex = this._findNext(true);
this._highlightCurrentMatch();
return Promise.resolve(
this.currentIndex !== undefined ? this._matches[this.currentIndex] : undefined,
);
} | /**
* Highlight the previous match
*
* @returns The previous match if available
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/search-highlighter.ts#L106-L112 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchHighlighter.setEditor | setEditor(editor: IEditor): void {
this.editor = editor;
this.refresh();
if (this.currentIndex !== undefined) {
this._highlightCurrentMatch();
}
} | /**
* Set the editor
*
* @param editor Editor
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search-code-cell/src/search-highlighter.ts#L119-L125 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchProvider.isApplicable | static isApplicable(domain: View): boolean {
return !!domain.container?.current;
} | /**
* Report whether or not this provider has the ability to search on the given object
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search/src/libro-search-generic-provider.ts#L35-L37 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchProvider.currentMatchIndex | override get currentMatchIndex(): number | undefined {
return this._currentMatchIndex >= 0 ? this._currentMatchIndex : undefined;
} | /**
* The current index of the selected match.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search/src/libro-search-generic-provider.ts#L42-L44 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchProvider.currentMatch | get currentMatch(): HTMLSearchMatch | undefined {
return this._matches[this._currentMatchIndex] ?? undefined;
} | /**
* The current match
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search/src/libro-search-generic-provider.ts#L49-L51 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchProvider.matches | get matches(): HTMLSearchMatch[] {
// Ensure that no other fn can overwrite matches index property
// We shallow clone each node
return this._matches
? this._matches.map((m) => Object.assign({}, m))
: this._matches;
} | /**
* The current matches
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search/src/libro-search-generic-provider.ts#L56-L62 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchProvider.matchesCount | override get matchesCount(): number | undefined {
return this._matches.length;
} | /**
* The number of matches.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search/src/libro-search-generic-provider.ts#L67-L69 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchProvider.clearHighlight | clearHighlight(): Promise<void> {
if (this._currentMatchIndex >= 0) {
const hit = this._markNodes[this._currentMatchIndex];
hit.classList.remove(...LIBRO_SEARCH_SELECTED_CLASSES);
}
this._currentMatchIndex = -1;
return Promise.resolve();
} | /**
* Clear currently highlighted match.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search/src/libro-search-generic-provider.ts#L84-L92 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchProvider.dispose | override dispose(): void {
if (this.isDisposed) {
return;
}
this.endQuery().catch((reason) => {
console.error(`Failed to end search query.`, reason);
});
super.dispose();
} | /**
* Dispose of the resources held by the search provider.
*
* #### Notes
* If the object's `dispose` method is called more than once, all
* calls made after the first will be a no-op.
*
* #### Undefined Behavior
* It is undefined behavior to use any functionality of the object
* after it ha... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search/src/libro-search-generic-provider.ts#L105-L114 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | GenericSearchProvider.highlightNext | async highlightNext(loop?: boolean): Promise<HTMLSearchMatch | undefined> {
return this._highlightNext(false, loop ?? true) ?? undefined;
} | /**
* Move the current match indicator to the next match.
*
* @param loop Whether to loop within the matches list.
*
* @returns A promise that resolves once the action has completed.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-search/src/libro-search-generic-provider.ts#L123-L125 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.