Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrebornix <penn.lv@gmail.com>2022-08-09 22:01:51 +0300
committerrebornix <penn.lv@gmail.com>2022-08-10 04:08:31 +0300
commit0b4552656762c2ffd321865f56e5b17687d63e3a (patch)
treeaa6694a07970bb7c5b85225f6c870bde881dd7d9 /src/vs/workbench/contrib/notebook/common
parent0eac052eb7f7bcd42c587f91b300fd07b89a3ba2 (diff)
notebook cell text buffer hash
Diffstat (limited to 'src/vs/workbench/contrib/notebook/common')
-rw-r--r--src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts b/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
index ae43a1b0bdf..a0c5de48b80 100644
--- a/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
+++ b/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Emitter, Event } from 'vs/base/common/event';
-import { hash } from 'vs/base/common/hash';
+import { hash, StringSHA1 } from 'vs/base/common/hash';
import { Disposable, DisposableStore, dispose } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import * as UUID from 'vs/base/common/uuid';
@@ -143,6 +143,7 @@ export class NotebookCellTextModel extends Disposable implements ICell {
return this._textBuffer;
}
+ private _textBufferHash: string | null = null;
private _hash: number | null = null;
private _versionId: number = 1;
@@ -224,12 +225,27 @@ export class NotebookCellTextModel extends Disposable implements ICell {
}
}
+ getTextBufferHash() {
+ if (this._textBufferHash !== null) {
+ return this._textBufferHash;
+ }
+
+ const shaComputer = new StringSHA1();
+ const snapshot = this.textBuffer.createSnapshot(false);
+ let text: string | null;
+ while ((text = snapshot.read())) {
+ shaComputer.update(text);
+ }
+ this._textBufferHash = shaComputer.digest();
+ return this._textBufferHash;
+ }
+
getHashValue(): number {
if (this._hash !== null) {
return this._hash;
}
- this._hash = hash([hash(this.language), hash(this.getValue()), this._getPersisentMetadata(), this.transientOptions.transientOutputs ? [] : this._outputs.map(op => ({
+ this._hash = hash([hash(this.language), this.getTextBufferHash(), this._getPersisentMetadata(), this.transientOptions.transientOutputs ? [] : this._outputs.map(op => ({
outputs: op.outputs.map(output => ({
mime: output.mime,
data: Array.from(output.data.buffer)