Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
56b067cf
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,发现更多精彩内容 >>
提交
56b067cf
编写于
1月 22, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adopt more snapshots
上级
0628d026
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
7 deletion
+25
-7
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+11
-0
src/vs/workbench/parts/files/electron-browser/saveErrorHandler.ts
...orkbench/parts/files/electron-browser/saveErrorHandler.ts
+3
-2
src/vs/workbench/services/textfile/common/textFileService.ts
src/vs/workbench/services/textfile/common/textFileService.ts
+5
-2
src/vs/workbench/services/textfile/electron-browser/textFileService.ts
...nch/services/textfile/electron-browser/textFileService.ts
+3
-1
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+3
-2
未找到文件。
src/vs/editor/common/model/textModel.ts
浏览文件 @
56b067cf
...
...
@@ -82,6 +82,17 @@ export function createTextBufferFactoryFromStream(stream: IStringStream): TPromi
});
}
export
function
createTextBufferFactoryFromSnapshot
(
snapshot
:
ITextSnapshot
):
model
.
ITextBufferFactory
{
let
builder
=
createTextBufferBuilder
();
let
chunk
:
string
;
while
(
typeof
(
chunk
=
snapshot
.
read
())
===
'
string
'
)
{
builder
.
acceptChunk
(
chunk
);
}
return
builder
.
finish
();
}
export
function
createTextBuffer
(
value
:
string
|
model
.
ITextBufferFactory
,
defaultEOL
:
model
.
DefaultEndOfLine
):
model
.
ITextBuffer
{
const
factory
=
(
typeof
value
===
'
string
'
?
createTextBufferFactory
(
value
)
:
value
);
return
factory
.
create
(
defaultEOL
);
...
...
src/vs/workbench/parts/files/electron-browser/saveErrorHandler.ts
浏览文件 @
56b067cf
...
...
@@ -31,6 +31,7 @@ import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEdi
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
SAVE_FILE_COMMAND_ID
,
REVERT_FILE_COMMAND_ID
,
SAVE_FILE_AS_COMMAND_ID
,
SAVE_FILE_AS_LABEL
}
from
'
vs/workbench/parts/files/electron-browser/fileCommands
'
;
import
{
createTextBufferFactoryFromSnapshot
}
from
'
vs/editor/common/model/textModel
'
;
export
const
CONFLICT_RESOLUTION_CONTEXT
=
'
saveConflictResolutionContext
'
;
export
const
CONFLICT_RESOLUTION_SCHEME
=
'
conflictResolution
'
;
...
...
@@ -262,7 +263,7 @@ export const acceptLocalChangesCommand = (accessor: ServicesAccessor, resource:
resolverService
.
createModelReference
(
resource
).
then
(
reference
=>
{
const
model
=
reference
.
object
as
ITextFileEditorModel
;
const
localModel
Value
=
model
.
getValue
();
const
localModel
Snapshot
=
model
.
createSnapshot
();
clearPendingResolveSaveConflictMessages
();
// hide any previously shown message about how to use these actions
...
...
@@ -270,7 +271,7 @@ export const acceptLocalChangesCommand = (accessor: ServicesAccessor, resource:
return
model
.
revert
().
then
(()
=>
{
// Restore user value (without loosing undo stack)
modelService
.
updateModel
(
model
.
textEditorModel
,
localModelValue
);
modelService
.
updateModel
(
model
.
textEditorModel
,
createTextBufferFactoryFromSnapshot
(
localModelSnapshot
)
);
// Trigger save
return
model
.
save
().
then
(()
=>
{
...
...
src/vs/workbench/services/textfile/common/textFileService.ts
浏览文件 @
56b067cf
...
...
@@ -32,6 +32,8 @@ import { Schemas } from 'vs/base/common/network';
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
IRevertOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
createTextBufferFactoryFromSnapshot
}
from
'
vs/editor/common/model/textModel
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
export
interface
IBackupResult
{
didBackup
:
boolean
;
...
...
@@ -73,7 +75,8 @@ export abstract class TextFileService implements ITextFileService {
private
backupFileService
:
IBackupFileService
,
private
windowsService
:
IWindowsService
,
private
historyService
:
IHistoryService
,
contextKeyService
:
IContextKeyService
contextKeyService
:
IContextKeyService
,
private
modelService
:
IModelService
)
{
this
.
toUnbind
=
[];
...
...
@@ -615,7 +618,7 @@ export abstract class TextFileService implements ITextFileService {
// take over encoding and model value from source model
targetModel
.
updatePreferredEncoding
(
sourceModel
.
getEncoding
());
t
argetModel
.
textEditorModel
.
setValue
(
sourceModel
.
getValue
(
));
t
his
.
modelService
.
updateModel
(
targetModel
.
textEditorModel
,
createTextBufferFactoryFromSnapshot
(
sourceModel
.
createSnapshot
()
));
// save model
return
targetModel
.
save
(
options
);
...
...
src/vs/workbench/services/textfile/electron-browser/textFileService.ts
浏览文件 @
56b067cf
...
...
@@ -30,6 +30,7 @@ import { IWindowsService, IWindowService } from 'vs/platform/windows/common/wind
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
mnemonicButtonLabel
}
from
'
vs/base/common/labels
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
export
class
TextFileService
extends
AbstractTextFileService
{
...
...
@@ -41,6 +42,7 @@ export class TextFileService extends AbstractTextFileService {
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IModeService
private
modeService
:
IModeService
,
@
IModelService
modelService
:
IModelService
,
@
IWindowService
private
windowService
:
IWindowService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IMessageService
messageService
:
IMessageService
,
...
...
@@ -49,7 +51,7 @@ export class TextFileService extends AbstractTextFileService {
@
IHistoryService
historyService
:
IHistoryService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
super
(
lifecycleService
,
contextService
,
configurationService
,
fileService
,
untitledEditorService
,
instantiationService
,
messageService
,
environmentService
,
backupFileService
,
windowsService
,
historyService
,
contextKeyService
);
super
(
lifecycleService
,
contextService
,
configurationService
,
fileService
,
untitledEditorService
,
instantiationService
,
messageService
,
environmentService
,
backupFileService
,
windowsService
,
historyService
,
contextKeyService
,
modelService
);
}
public
resolveTextContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IRawTextContent
>
{
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
56b067cf
...
...
@@ -180,9 +180,10 @@ export class TestTextFileService extends TextFileService {
@
IBackupFileService
backupFileService
:
IBackupFileService
,
@
IWindowsService
windowsService
:
IWindowsService
,
@
IHistoryService
historyService
:
IHistoryService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IModelService
modelService
:
IModelService
)
{
super
(
lifecycleService
,
contextService
,
configurationService
,
fileService
,
untitledEditorService
,
instantiationService
,
messageService
,
TestEnvironmentService
,
backupFileService
,
windowsService
,
historyService
,
contextKeyService
);
super
(
lifecycleService
,
contextService
,
configurationService
,
fileService
,
untitledEditorService
,
instantiationService
,
messageService
,
TestEnvironmentService
,
backupFileService
,
windowsService
,
historyService
,
contextKeyService
,
modelService
);
}
public
setPromptPath
(
path
:
string
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录