Открыть боковую панель
code
vscode
Коммиты
f6b2d7a3
Не подтверждена
Коммит
f6b2d7a3
создал
Апр 08, 2025
по автору
Aaron Munger
Зафиксировано автором
GitHub
Апр 08, 2025
Просмотр файлов
port fix to main (#246011)
владелец
4095bbc1
Изменения
3
Развернуть все
Скрыть пробелы
Построчно
Рядом
src/vs/platform/terminal/node/terminalEnvironment.ts
Просмотр файла @
f6b2d7a3
...
...
@@ -15,6 +15,8 @@ import { IShellLaunchConfig, ITerminalEnvironment, ITerminalProcessOptions, Shel
import
{
EnvironmentVariableMutatorType
}
from
'
../common/environmentVariable.js
'
;
import
{
deserializeEnvironmentVariableCollections
}
from
'
../common/environmentVariableShared.js
'
;
import
{
MergedEnvironmentVariableCollection
}
from
'
../common/environmentVariableCollection.js
'
;
import
{
chmod
,
realpathSync
}
from
'
fs
'
;
import
{
promisify
}
from
'
util
'
;
export
function
getWindowsBuildNumber
():
number
{
const
osVersion
=
(
/
(\d
+
)\.(\d
+
)\.(\d
+
)
/g
).
exec
(
os
.
release
());
...
...
@@ -55,13 +57,14 @@ export interface IShellIntegrationInjectionFailure {
* that creates the process to ensure accuracy. Returns undefined if shell integration cannot be
* enabled.
*/
export
function
getShellIntegrationInjection
(
export
async
function
getShellIntegrationInjection
(
shellLaunchConfig
:
IShellLaunchConfig
,
options
:
ITerminalProcessOptions
,
env
:
ITerminalEnvironment
|
undefined
,
logService
:
ILogService
,
productService
:
IProductService
):
IShellIntegrationConfigInjection
|
IShellIntegrationInjectionFailure
{
productService
:
IProductService
,
skipStickyBit
:
boolean
=
false
):
Promise
<
IShellIntegrationConfigInjection
|
IShellIntegrationInjectionFailure
>
{
// The global setting is disabled
if
(
!
options
.
shellIntegration
.
enabled
)
{
return
{
type
:
'
failure
'
,
reason
:
ShellIntegrationInjectionFailureReason
.
InjectionSettingDisabled
};
...
...
@@ -220,7 +223,27 @@ export function getShellIntegrationInjection(
}
catch
{
username
=
'
unknown
'
;
}
const
zdotdir
=
path
.
join
(
os
.
tmpdir
(),
`
${
username
}
-
${
productService
.
applicationName
}
-zsh`
);
// Resolve the actual tmp directory so we can set the sticky bit
const
realTmpDir
=
realpathSync
(
os
.
tmpdir
());
const
zdotdir
=
path
.
join
(
realTmpDir
,
`
${
username
}
-
${
productService
.
applicationName
}
-zsh`
);
// Set directory permissions using octal notation:
// - 0o1700:
// - Sticky bit is set, preventing non-owners from deleting or renaming files within this directory (1)
// - Owner has full read (4), write (2), execute (1) permissions
// - Group has no permissions (0)
// - Others have no permissions (0)
if
(
!
skipStickyBit
)
{
// skip for tests
try
{
const
chmodAsync
=
promisify
(
chmod
);
await
chmodAsync
(
zdotdir
,
0o1700
);
}
catch
(
err
)
{
logService
.
error
(
`Failed to set sticky bit on
${
zdotdir
}
:
${
err
}
`
);
return
{
type
:
'
failure
'
,
reason
:
ShellIntegrationInjectionFailureReason
.
UnsupportedShell
};
}
}
envMixin
[
'
ZDOTDIR
'
]
=
zdotdir
;
const
userZdotdir
=
env
?.
ZDOTDIR
??
os
.
homedir
()
??
`~`
;
envMixin
[
'
USER_ZDOTDIR
'
]
=
userZdotdir
;
...
...
src/vs/platform/terminal/node/terminalProcess.ts
Просмотр файла @
f6b2d7a3
...
...
@@ -209,7 +209,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
return
firstError
;
}
const
injection
=
getShellIntegrationInjection
(
this
.
shellLaunchConfig
,
this
.
_options
,
this
.
_ptyOptions
.
env
,
this
.
_logService
,
this
.
_productService
);
const
injection
=
await
getShellIntegrationInjection
(
this
.
shellLaunchConfig
,
this
.
_options
,
this
.
_ptyOptions
.
env
,
this
.
_logService
,
this
.
_productService
);
if
(
injection
.
type
===
'
injection
'
)
{
this
.
_onDidChangeProperty
.
fire
({
type
:
ProcessPropertyType
.
UsedShellIntegrationInjection
,
value
:
true
});
if
(
injection
.
envMixin
)
{
...
...
src/vs/platform/terminal/test/node/terminalEnvironment.test.ts
Просмотр файла @
f6b2d7a3
Это отличие свёрнуто
Нажмите, чтобы развернуть
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать