Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
e88c040d
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e88c040d
编写于
8月 26, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ignore transient metadata in diff editor.
上级
7c986e94
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
57 addition
and
74 deletion
+57
-74
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts
...workbench/contrib/notebook/browser/diff/cellComponents.ts
+18
-3
src/vs/workbench/contrib/notebook/browser/diff/common.ts
src/vs/workbench/contrib/notebook/browser/diff/common.ts
+2
-0
src/vs/workbench/contrib/notebook/browser/diff/notebookTextDiffEditor.ts
...h/contrib/notebook/browser/diff/notebookTextDiffEditor.ts
+10
-5
src/vs/workbench/contrib/notebook/browser/notebookDiffEditorInput.ts
...bench/contrib/notebook/browser/notebookDiffEditorInput.ts
+0
-8
src/vs/workbench/contrib/notebook/common/model/cellEdit.ts
src/vs/workbench/contrib/notebook/common/model/cellEdit.ts
+3
-3
src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
...ch/contrib/notebook/common/model/notebookCellTextModel.ts
+3
-3
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+12
-49
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+1
-1
src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.ts
...rib/notebook/common/notebookEditorModelResolverService.ts
+6
-0
未找到文件。
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
e88c040d
...
...
@@ -428,9 +428,9 @@ export class ExtHostNotebookDocument extends Disposable {
this
.
_emitter
.
emitCellLanguageChange
(
event
);
}
private
_changeCellMetadata
(
index
:
number
,
newMetadata
:
NotebookCellMetadata
):
void
{
private
_changeCellMetadata
(
index
:
number
,
newMetadata
:
NotebookCellMetadata
|
undefined
):
void
{
const
cell
=
this
.
_cells
[
index
];
cell
.
setMetadata
(
newMetadata
);
cell
.
setMetadata
(
newMetadata
||
{}
);
const
event
:
vscode
.
NotebookCellMetadataChangeEvent
=
{
document
:
this
.
notebookDocument
,
cell
:
cell
.
cell
};
this
.
_emitter
.
emitCellMetadataChange
(
event
);
}
...
...
src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts
浏览文件 @
e88c040d
...
...
@@ -235,7 +235,7 @@ abstract class AbstractCellRenderer extends Disposable {
{
updateInfoRendering
:
this
.
updateMetadataRendering
.
bind
(
this
),
checkIfModified
:
(
cell
)
=>
{
return
cell
.
type
===
'
modified
'
&&
hash
(
cell
.
original
?.
metadata
??
{})
!==
hash
(
cell
.
modified
?.
metadata
??
{}
);
return
cell
.
type
===
'
modified
'
&&
hash
(
this
.
_getFormatedMetadataJSON
(
cell
.
original
?.
metadata
||
{}))
!==
hash
(
this
.
_getFormatedMetadataJSON
(
cell
.
modified
?.
metadata
??
{})
);
},
getFoldingState
:
(
cell
)
=>
{
return
cell
.
metadataFoldingState
;
...
...
@@ -321,10 +321,25 @@ abstract class AbstractCellRenderer extends Disposable {
}
}
private
_getFormatedMetadataJSON
(
metadata
:
NotebookCellMetadata
,
language
?:
string
)
{
protected
_getFormatedMetadataJSON
(
metadata
:
NotebookCellMetadata
,
language
?:
string
)
{
let
filteredMetadata
:
{
[
key
:
string
]:
any
}
=
{};
if
(
this
.
notebookEditor
.
textModel
)
{
const
transientMetadata
=
this
.
notebookEditor
.
textModel
!
.
transientMetadata
;
const
keys
=
new
Set
([...
Object
.
keys
(
metadata
)]);
for
(
let
key
of
keys
)
{
if
(
!
(
transientMetadata
[
key
as
keyof
NotebookCellMetadata
])
)
{
filteredMetadata
[
key
]
=
metadata
[
key
as
keyof
NotebookCellMetadata
];
}
}
}
else
{
filteredMetadata
=
metadata
;
}
const
content
=
JSON
.
stringify
({
language
,
...
m
etadata
...
filteredM
etadata
});
const
edits
=
format
(
content
,
undefined
,
{});
...
...
src/vs/workbench/contrib/notebook/browser/diff/common.ts
浏览文件 @
e88c040d
...
...
@@ -8,8 +8,10 @@ import { CellDiffViewModel } from 'vs/workbench/contrib/notebook/browser/diff/ce
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
BareFontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
export
interface
INotebookTextDiffEditor
{
readonly
textModel
?:
NotebookTextModel
;
onMouseUp
:
Event
<
{
readonly
event
:
MouseEvent
;
readonly
target
:
CellDiffViewModel
;
}
>
;
getOverflowContainerDomNode
():
HTMLElement
;
getLayoutInfo
():
NotebookLayoutInfo
;
...
...
src/vs/workbench/contrib/notebook/browser/diff/notebookTextDiffEditor.ts
浏览文件 @
e88c040d
...
...
@@ -30,6 +30,7 @@ import { Emitter } from 'vs/base/common/event';
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
NotebookDiffEditorEventDispatcher
,
NotebookLayoutChangedEvent
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher
'
;
import
{
EditorPane
}
from
'
vs/workbench/browser/parts/editor/editorPane
'
;
import
{
INotebookDiffEditorModel
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
export
const
IN_NOTEBOOK_TEXT_DIFF_EDITOR
=
new
RawContextKey
<
boolean
>
(
'
isInNotebookTextDiffEditor
'
,
false
);
...
...
@@ -46,6 +47,10 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
public
readonly
onMouseUp
=
this
.
_onMouseUp
.
event
;
private
_eventDispatcher
:
NotebookDiffEditorEventDispatcher
|
undefined
;
protected
_scopeContextKeyService
!
:
IContextKeyService
;
private
_model
:
INotebookDiffEditorModel
|
null
=
null
;
get
textModel
()
{
return
this
.
_model
?.
modified
.
notebook
;
}
constructor
(
@
IInstantiationService
readonly
instantiationService
:
IInstantiationService
,
...
...
@@ -132,19 +137,19 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
async
setInput
(
input
:
NotebookDiffEditorInput
,
options
:
EditorOptions
|
undefined
,
context
:
IEditorOpenContext
,
token
:
CancellationToken
):
Promise
<
void
>
{
await
super
.
setInput
(
input
,
options
,
context
,
token
);
const
model
=
await
input
.
resolve
();
if
(
model
===
null
)
{
this
.
_
model
=
await
input
.
resolve
();
if
(
this
.
_
model
===
null
)
{
return
;
}
this
.
_eventDispatcher
=
new
NotebookDiffEditorEventDispatcher
();
const
diffResult
=
await
this
.
notebookEditorWorkerService
.
computeDiff
(
model
.
original
.
resource
,
model
.
modified
.
resource
);
const
diffResult
=
await
this
.
notebookEditorWorkerService
.
computeDiff
(
this
.
_model
.
original
.
resource
,
this
.
_
model
.
modified
.
resource
);
const
cellChanges
=
diffResult
.
cellsDiff
.
changes
;
const
cellDiffViewModels
:
CellDiffViewModel
[]
=
[];
const
originalModel
=
model
.
original
.
notebook
;
const
modifiedModel
=
model
.
modified
.
notebook
;
const
originalModel
=
this
.
_
model
.
original
.
notebook
;
const
modifiedModel
=
this
.
_
model
.
modified
.
notebook
;
let
originalCellIndex
=
0
;
let
modifiedCellIndex
=
0
;
...
...
src/vs/workbench/contrib/notebook/browser/notebookDiffEditorInput.ts
浏览文件 @
e88c040d
...
...
@@ -198,14 +198,6 @@ ${patterns}
if
(
!
this
.
_textModel
)
{
this
.
_textModel
=
await
this
.
_notebookModelResolverService
.
resolve
(
this
.
resource
,
this
.
viewType
!
,
editorId
);
this
.
_originalTextModel
=
await
this
.
_notebookModelResolverService
.
resolve
(
this
.
originalResource
,
this
.
viewType
!
,
editorId
);
// this._register(this._textModel.object.onDidChangeDirty(() => {
// this._onDidChangeDirty.fire();
// }));
// if (this._textModel.object.isDirty()) {
// this._onDidChangeDirty.fire();
// }
}
return
new
NotebookDiffEditorModel
(
this
.
_originalTextModel
!
.
object
as
NotebookEditorModel
,
this
.
_textModel
.
object
as
NotebookEditorModel
);
...
...
src/vs/workbench/contrib/notebook/common/model/cellEdit.ts
浏览文件 @
e88c040d
...
...
@@ -15,7 +15,7 @@ export interface ITextCellEditingDelegate {
insertCell
?(
index
:
number
,
cell
:
NotebookCellTextModel
):
void
;
deleteCell
?(
index
:
number
):
void
;
moveCell
?(
fromIndex
:
number
,
length
:
number
,
toIndex
:
number
,
beforeSelections
:
number
[]
|
undefined
,
endSelections
:
number
[]
|
undefined
):
void
;
updateCellMetadata
?(
index
:
number
,
newMetadata
:
NotebookCellMetadata
|
undefined
):
void
;
updateCellMetadata
?(
index
:
number
,
newMetadata
:
NotebookCellMetadata
):
void
;
emitSelections
(
selections
:
number
[]):
void
;
}
...
...
@@ -192,8 +192,8 @@ export class CellMetadataEdit implements IResourceUndoRedoElement {
constructor
(
public
resource
:
URI
,
readonly
index
:
number
,
readonly
oldMetadata
:
NotebookCellMetadata
|
undefined
,
readonly
newMetadata
:
NotebookCellMetadata
|
undefined
,
readonly
oldMetadata
:
NotebookCellMetadata
,
readonly
newMetadata
:
NotebookCellMetadata
,
private
editingDelegate
:
ITextCellEditingDelegate
,
)
{
...
...
src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
浏览文件 @
e88c040d
...
...
@@ -32,13 +32,13 @@ export class NotebookCellTextModel extends Disposable implements ICell {
return
this
.
_outputs
;
}
private
_metadata
:
NotebookCellMetadata
|
undefined
;
private
_metadata
:
NotebookCellMetadata
;
get
metadata
()
{
return
this
.
_metadata
;
}
set
metadata
(
newMetadata
:
NotebookCellMetadata
|
undefined
)
{
set
metadata
(
newMetadata
:
NotebookCellMetadata
)
{
this
.
_metadata
=
newMetadata
;
this
.
_hash
=
null
;
this
.
_onDidChangeMetadata
.
fire
();
...
...
@@ -89,7 +89,7 @@ export class NotebookCellTextModel extends Disposable implements ICell {
)
{
super
();
this
.
_outputs
=
outputs
;
this
.
_metadata
=
metadata
;
this
.
_metadata
=
metadata
||
{}
;
}
getValue
():
string
{
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
e88c040d
...
...
@@ -187,7 +187,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
)
{
const
cellHandle
=
this
.
_cellhandlePool
++
;
const
cellUri
=
CellUri
.
generate
(
this
.
uri
,
cellHandle
);
return
new
NotebookCellTextModel
(
cellUri
,
cellHandle
,
source
,
language
,
cellKind
,
outputs
||
[],
metadata
,
this
.
_modelService
);
return
new
NotebookCellTextModel
(
cellUri
,
cellHandle
,
source
,
language
,
cellKind
,
outputs
||
[],
metadata
||
{}
,
this
.
_modelService
);
}
initialize
(
cells
:
ICellDto2
[])
{
...
...
@@ -497,59 +497,22 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
}
}
private
_compareCellMetadata
(
a
:
NotebookCellMetadata
|
undefined
,
b
:
NotebookCellMetadata
|
undefined
)
{
if
(
a
?.
editable
!==
b
?.
editable
&&
!
this
.
transientMetadata
.
editable
)
{
return
true
;
}
if
(
a
?.
runnable
!==
b
?.
runnable
&&
!
this
.
transientMetadata
.
runnable
)
{
return
true
;
}
if
(
a
?.
breakpointMargin
!==
b
?.
breakpointMargin
&&
!
this
.
transientMetadata
.
breakpointMargin
)
{
return
true
;
}
if
(
a
?.
hasExecutionOrder
!==
b
?.
hasExecutionOrder
&&
!
this
.
transientMetadata
.
hasExecutionOrder
)
{
return
true
;
}
if
(
a
?.
executionOrder
!==
b
?.
executionOrder
&&
!
this
.
transientMetadata
.
executionOrder
)
{
return
true
;
}
if
(
a
?.
statusMessage
!==
b
?.
statusMessage
&&
!
this
.
transientMetadata
.
statusMessage
)
{
return
true
;
}
if
(
a
?.
runState
!==
b
?.
runState
&&
!
this
.
transientMetadata
.
runState
)
{
return
true
;
}
if
(
a
?.
runStartTime
!==
b
?.
runStartTime
&&
!
this
.
transientMetadata
.
runStartTime
)
{
return
true
;
}
if
(
a
?.
lastRunDuration
!==
b
?.
lastRunDuration
&&
!
this
.
transientMetadata
.
lastRunDuration
)
{
return
true
;
}
if
(
a
?.
inputCollapsed
!==
b
?.
inputCollapsed
&&
!
this
.
transientMetadata
.
inputCollapsed
)
{
return
true
;
}
if
(
a
?.
outputCollapsed
!==
b
?.
outputCollapsed
&&
!
this
.
transientMetadata
.
outputCollapsed
)
{
return
true
;
}
if
(
a
?.
custom
!==
b
?.
custom
&&
!
this
.
transientMetadata
.
custom
)
{
return
true
;
private
_compareCellMetadata
(
a
:
NotebookCellMetadata
,
b
:
NotebookCellMetadata
)
{
const
keys
=
new
Set
([...
Object
.
keys
(
a
||
{}),
...
Object
.
keys
(
b
||
{})]);
for
(
let
key
of
keys
)
{
if
(
(
a
[
key
as
keyof
NotebookCellMetadata
]
!==
b
[
key
as
keyof
NotebookCellMetadata
])
&&
!
(
this
.
transientMetadata
[
key
as
keyof
NotebookCellMetadata
])
)
{
return
true
;
}
}
return
false
;
}
changeCellMetadata
(
handle
:
number
,
metadata
:
NotebookCellMetadata
|
undefined
,
pushUndoStop
:
boolean
)
{
changeCellMetadata
(
handle
:
number
,
metadata
:
NotebookCellMetadata
,
pushUndoStop
:
boolean
)
{
const
cell
=
this
.
cells
.
find
(
cell
=>
cell
.
handle
===
handle
);
if
(
!
cell
)
{
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
e88c040d
...
...
@@ -397,7 +397,7 @@ export interface NotebookCellsChangeMetadataEvent {
readonly
kind
:
NotebookCellsChangeType
.
ChangeMetadata
;
readonly
versionId
:
number
;
readonly
index
:
number
;
readonly
metadata
:
NotebookCellMetadata
;
readonly
metadata
:
NotebookCellMetadata
|
undefined
;
}
export
type
NotebookCellsChangedEvent
=
NotebookCellsInitializeEvent
|
NotebookCellsModelChangedEvent
|
NotebookCellsModelMoveEvent
|
NotebookCellClearOutputEvent
|
NotebookCellsClearOutputEvent
|
NotebookCellsChangeLanguageEvent
|
NotebookCellsChangeMetadataEvent
;
...
...
src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.ts
浏览文件 @
e88c040d
...
...
@@ -76,3 +76,9 @@ export class NotebookModelResolverService implements INotebookEditorModelResolve
};
}
}
// notebookService.onDidAddDocument
// resolve()
// notebookService.onDidRemoveDocument ...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录