mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Notebook Tokenization Fixes (#7375)
* Fix don't like; unclear if grammar necessssary too * Cleanup and sanity check * Cleanup and sanity check * Add test * Call onBeforeAttached for 3 types of editor models
This commit is contained in:
@@ -341,10 +341,17 @@ export class NotebookInput extends EditorInput {
|
||||
} else {
|
||||
let textOrUntitledEditorModel: UntitledEditorModel | IEditorModel;
|
||||
if (this.resource.scheme === Schemas.untitled) {
|
||||
textOrUntitledEditorModel = this._untitledEditorModel ? this._untitledEditorModel : await this._textInput.resolve();
|
||||
}
|
||||
else {
|
||||
if (this._untitledEditorModel) {
|
||||
this._untitledEditorModel.textEditorModel.onBeforeAttached();
|
||||
textOrUntitledEditorModel = this._untitledEditorModel;
|
||||
} else {
|
||||
let resolvedInput = await this._textInput.resolve();
|
||||
resolvedInput.textEditorModel.onBeforeAttached();
|
||||
textOrUntitledEditorModel = resolvedInput;
|
||||
}
|
||||
} else {
|
||||
const textEditorModelReference = await this.textModelService.createModelReference(this.resource);
|
||||
textEditorModelReference.object.textEditorModel.onBeforeAttached();
|
||||
textOrUntitledEditorModel = await textEditorModelReference.object.load();
|
||||
}
|
||||
this._model = this.instantiationService.createInstance(NotebookEditorModel, this.resource, textOrUntitledEditorModel);
|
||||
@@ -385,6 +392,9 @@ export class NotebookInput extends EditorInput {
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this._model) {
|
||||
this._model.editorModel.textEditorModel.onBeforeDetached();
|
||||
}
|
||||
this._disposeContainer();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -69,17 +69,23 @@ export class NotebookTextFileModel {
|
||||
} else {
|
||||
newOutput = '\n'.concat(newOutput).concat('\n');
|
||||
}
|
||||
let range = this.getEndOfOutputs(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
if (range) {
|
||||
|
||||
// Execution count will always be after the end of the outputs in JSON. This is a sanity mechanism.
|
||||
let executionCountMatch = this.getExecutionCountRange(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
if (!executionCountMatch || !executionCountMatch.range) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let endOutputsRange = this.getEndOfOutputs(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
if (endOutputsRange && endOutputsRange.startLineNumber < executionCountMatch.range.startLineNumber) {
|
||||
textEditorModel.textEditorModel.applyEdits([{
|
||||
range: new Range(range.startLineNumber, range.startColumn, range.startLineNumber, range.startColumn),
|
||||
range: new Range(endOutputsRange.startLineNumber, endOutputsRange.startColumn, endOutputsRange.startLineNumber, endOutputsRange.startColumn),
|
||||
text: newOutput
|
||||
}]);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public transformAndApplyEditForCellUpdated(contentChange: NotebookContentChange, textEditorModel: TextFileEditorModel | UntitledEditorModel): boolean {
|
||||
|
||||
Reference in New Issue
Block a user