Fix intellisense for .NET Interactive SQL kernel (#19254)

This commit is contained in:
Cory Rivera
2022-05-02 13:44:33 -07:00
committed by GitHub
parent bfd878bff7
commit 8cc66dade3
11 changed files with 52 additions and 6 deletions

View File

@@ -33,6 +33,8 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { IPathService } from 'vs/workbench/services/path/common/pathService';
import { diffSets, diffMaps } from 'vs/base/common/collections';
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
import { Schemas } from 'vs/base/common/network';
import { CELL_URI_PATH_PREFIX } from 'sql/workbench/common/constants';
class TextEditorSnapshot {
@@ -390,13 +392,20 @@ export class MainThreadDocumentsAndEditors {
}
private _toModelAddData(model: ITextModel): IModelAddedData {
// {{SQL CARBON EDIT}}
// Check if this TextModel is part of a notebook cell
let notebookUri: URI;
if (model.uri.scheme === Schemas.untitled && model.uri.path.startsWith(CELL_URI_PATH_PREFIX)) {
notebookUri = this._notebookService.getNotebookURIForCell(model.uri);
}
return {
uri: model.uri,
versionId: model.getVersionId(),
lines: model.getLinesContent(),
EOL: model.getEOL(),
modeId: model.getLanguageIdentifier().language,
isDirty: this._textFileService.isDirty(model.uri)
isDirty: this._textFileService.isDirty(model.uri),
notebookUri: notebookUri
};
}

View File

@@ -1212,6 +1212,8 @@ export interface IModelAddedData {
EOL: string;
modeId: string;
isDirty: boolean;
// {{SQL CARBON EDIT}}
notebookUri?: URI;
}
export interface ExtHostDocumentsShape {
$acceptModelModeChanged(strURL: UriComponents, newModeId: string): void;

View File

@@ -97,6 +97,14 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
}
}
if (!ref) {
// {{SQL CARBON EDIT}}
// Add URI of the notebook that is using this document for a cell's editor.
if (!data.notebook && data.notebookUri) {
// We only use this notebook field for .NET Interactive's intellisense, which only uses the notebook's URI
data.notebook = <vscode.NotebookDocument>{
uri: URI.revive(data.notebookUri)
};
}
ref = new Reference(new ExtHostDocumentData(
this._extHostRpc.getProxy(MainContext.MainThreadDocuments),
resource,

View File

@@ -11,6 +11,7 @@ import { Disposable, IDisposable, toDisposable, DisposableStore, dispose } from
import { ResourceMap } from 'vs/base/common/map';
import { IWorkingCopy, IWorkingCopyIdentifier } from 'vs/workbench/services/workingCopy/common/workingCopy';
import { Schemas } from 'vs/base/common/network'; // {{SQL CARBON EDIT}} @chlafreniere need to block working copies of notebook editors from being tracked
import { CELL_URI_PATH_PREFIX } from 'sql/workbench/common/constants';
export const IWorkingCopyService = createDecorator<IWorkingCopyService>('workingCopyService');
@@ -142,7 +143,7 @@ export class WorkingCopyService extends Disposable implements IWorkingCopyServic
}
// {{SQL CARBON EDIT}} @chlafreniere need to block working copies of notebook editors from being tracked
if (workingCopy.resource.path.includes('notebook-editor-') && workingCopy.resource.scheme === Schemas.untitled) {
if (workingCopy.resource.path.includes(CELL_URI_PATH_PREFIX) && workingCopy.resource.scheme === Schemas.untitled) {
return new DisposableStore();
}