Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c241e1d5
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c241e1d5
编写于
10月 01, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Making status bar items for images more reliable
Fixes #81738
上级
47ac64a0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
28 deletion
+47
-28
extensions/image-preview/src/preview.ts
extensions/image-preview/src/preview.ts
+26
-13
extensions/image-preview/src/sizeStatusBarEntry.ts
extensions/image-preview/src/sizeStatusBarEntry.ts
+10
-7
extensions/image-preview/src/zoomStatusBarEntry.ts
extensions/image-preview/src/zoomStatusBarEntry.ts
+11
-8
未找到文件。
extensions/image-preview/src/preview.ts
浏览文件 @
c241e1d5
...
...
@@ -5,7 +5,7 @@
import
*
as
vscode
from
'
vscode
'
;
import
{
SizeStatusBarEntry
}
from
'
./sizeStatusBarEntry
'
;
import
{
ZoomStatusBarEntry
}
from
'
./zoomStatusBarEntry
'
;
import
{
ZoomStatusBarEntry
,
Scale
}
from
'
./zoomStatusBarEntry
'
;
import
{
Disposable
}
from
'
./dispose
'
;
const
enum
PreviewState
{
...
...
@@ -18,7 +18,11 @@ export class Preview extends Disposable {
public
static
readonly
viewType
=
'
imagePreview.previewEditor
'
;
private
readonly
id
:
string
=
`
${
Date
.
now
()}
-
${
Math
.
random
().
toString
()}
`
;
private
_previewState
=
PreviewState
.
Visible
;
private
_imageSize
:
string
|
undefined
;
private
_imageZoom
:
Scale
|
undefined
;
constructor
(
private
readonly
extensionRoot
:
vscode
.
Uri
,
...
...
@@ -44,12 +48,14 @@ export class Preview extends Disposable {
switch
(
message
.
type
)
{
case
'
size
'
:
{
this
.
sizeStatusBarEntry
.
update
(
message
.
value
);
this
.
_imageSize
=
message
.
value
;
this
.
update
();
break
;
}
case
'
zoom
'
:
{
this
.
zoomStatusBarEntry
.
update
(
message
.
value
);
this
.
_imageZoom
=
message
.
value
;
this
.
update
();
break
;
}
}
...
...
@@ -67,8 +73,8 @@ export class Preview extends Disposable {
this
.
_register
(
webviewEditor
.
onDidDispose
(()
=>
{
if
(
this
.
_previewState
===
PreviewState
.
Active
)
{
this
.
sizeStatusBarEntry
.
hide
();
this
.
zoomStatusBarEntry
.
hide
();
this
.
sizeStatusBarEntry
.
hide
(
this
.
id
);
this
.
zoomStatusBarEntry
.
hide
(
this
.
id
);
}
this
.
_previewState
=
PreviewState
.
Disposed
;
}));
...
...
@@ -97,12 +103,14 @@ export class Preview extends Disposable {
if
(
this
.
webviewEditor
.
active
)
{
this
.
_previewState
=
PreviewState
.
Active
;
this
.
sizeStatusBarEntry
.
show
();
this
.
zoomStatusBarEntry
.
show
();
this
.
sizeStatusBarEntry
.
show
(
this
.
id
,
this
.
_imageSize
||
''
);
this
.
zoomStatusBarEntry
.
show
(
this
.
id
,
this
.
_imageZoom
||
'
fit
'
);
}
else
{
if
(
this
.
_previewState
===
PreviewState
.
Active
)
{
this
.
sizeStatusBarEntry
.
hide
(
this
.
id
);
this
.
zoomStatusBarEntry
.
hide
(
this
.
id
);
}
this
.
_previewState
=
PreviewState
.
Visible
;
this
.
sizeStatusBarEntry
.
hide
();
this
.
zoomStatusBarEntry
.
hide
();
}
}
...
...
@@ -132,11 +140,16 @@ export class Preview extends Disposable {
}
private
getResourcePath
(
webviewEditor
:
vscode
.
WebviewEditor
,
resource
:
vscode
.
Uri
,
version
:
string
)
{
if
(
resource
.
scheme
===
'
data
'
)
{
return
encodeURI
(
resource
.
toString
(
true
));
}
switch
(
resource
.
scheme
)
{
case
'
data
'
:
return
encodeURI
(
resource
.
toString
(
true
));
return
encodeURI
(
webviewEditor
.
webview
.
asWebviewUri
(
resource
).
toString
(
true
)
+
`?version=
${
version
}
`
);
case
'
git
'
:
default
:
return
encodeURI
(
webviewEditor
.
webview
.
asWebviewUri
(
resource
).
toString
(
true
)
+
`?version=
${
version
}
`
);
}
}
private
extensionResource
(
path
:
string
)
{
...
...
extensions/image-preview/src/sizeStatusBarEntry.ts
浏览文件 @
c241e1d5
...
...
@@ -12,6 +12,8 @@ const localize = nls.loadMessageBundle();
export
class
SizeStatusBarEntry
extends
Disposable
{
private
readonly
_entry
:
vscode
.
StatusBarItem
;
private
_showingOwner
:
string
|
undefined
;
constructor
()
{
super
();
this
.
_entry
=
this
.
_register
(
vscode
.
window
.
createStatusBarItem
({
...
...
@@ -22,15 +24,16 @@ export class SizeStatusBarEntry extends Disposable {
}));
}
public
show
()
{
public
show
(
owner
:
string
,
text
:
string
)
{
this
.
_showingOwner
=
owner
;
this
.
_entry
.
text
=
text
;
this
.
_entry
.
show
();
}
public
hide
()
{
this
.
_entry
.
hide
();
}
public
update
(
text
:
string
)
{
this
.
_entry
.
text
=
text
;
public
hide
(
owner
:
string
)
{
if
(
owner
===
this
.
_showingOwner
)
{
this
.
_entry
.
hide
();
this
.
_showingOwner
=
undefined
;
}
}
}
extensions/image-preview/src/zoomStatusBarEntry.ts
浏览文件 @
c241e1d5
...
...
@@ -11,7 +11,7 @@ const localize = nls.loadMessageBundle();
const
selectZoomLevelCommandId
=
'
_imagePreview.selectZoomLevel
'
;
type
Scale
=
number
|
'
fit
'
;
export
type
Scale
=
number
|
'
fit
'
;
export
class
ZoomStatusBarEntry
extends
Disposable
{
private
readonly
_entry
:
vscode
.
StatusBarItem
;
...
...
@@ -19,6 +19,8 @@ export class ZoomStatusBarEntry extends Disposable {
private
readonly
_onDidChangeScale
=
this
.
_register
(
new
vscode
.
EventEmitter
<
{
scale
:
Scale
}
>
());
public
readonly
onDidChangeScale
=
this
.
_onDidChangeScale
.
event
;
private
_showOwner
:
string
|
undefined
;
constructor
()
{
super
();
this
.
_entry
=
this
.
_register
(
vscode
.
window
.
createStatusBarItem
({
...
...
@@ -48,16 +50,17 @@ export class ZoomStatusBarEntry extends Disposable {
this
.
_entry
.
command
=
selectZoomLevelCommandId
;
}
public
show
()
{
public
show
(
owner
:
string
,
scale
:
Scale
)
{
this
.
_showOwner
=
owner
;
this
.
_entry
.
text
=
this
.
zoomLabel
(
scale
);
this
.
_entry
.
show
();
}
public
hide
()
{
this
.
_entry
.
hide
();
}
public
update
(
scale
:
Scale
)
{
this
.
_entry
.
text
=
this
.
zoomLabel
(
scale
);
public
hide
(
owner
:
string
)
{
if
(
owner
===
this
.
_showOwner
)
{
this
.
_entry
.
hide
();
this
.
_showOwner
=
undefined
;
}
}
private
zoomLabel
(
scale
:
Scale
):
string
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录