Skip to content

Commit

Permalink
Rebase against the upstream f6d9f0e
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: f6d9f0e
  • Loading branch information
Eclipse Che Sync committed Aug 29, 2024
2 parents ee1117d + f6d9f0e commit 954282f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 27 deletions.
23 changes: 13 additions & 10 deletions code/src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
private _gutterState: LightBulbState.State = LightBulbState.Hidden;
private _iconClasses: string[] = [];

private readonly lightbulbClasses = [
'codicon-' + GUTTER_LIGHTBULB_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AUTO_FIX_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AIFIX_ICON.id,
'codicon-' + GUTTER_SPARKLE_FILLED_ICON.id
];

private _preferredKbLabel?: string;
private _quickFixKbLabel?: string;

Expand Down Expand Up @@ -148,15 +156,8 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
}));

this._register(this._editor.onMouseDown(async (e: IEditorMouseEvent) => {
const lightbulbClasses = [
'codicon-' + GUTTER_LIGHTBULB_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AUTO_FIX_ICON.id,
'codicon-' + GUTTER_LIGHTBULB_AIFIX_ICON.id,
'codicon-' + GUTTER_SPARKLE_FILLED_ICON.id
];

if (!e.target.element || !lightbulbClasses.some(cls => e.target.element && e.target.element.classList.contains(cls))) {

if (!e.target.element || !this.lightbulbClasses.some(cls => e.target.element && e.target.element.classList.contains(cls))) {
return;
}

Expand Down Expand Up @@ -247,7 +248,9 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
let hasDecoration = false;
if (currLineDecorations) {
for (const decoration of currLineDecorations) {
if (decoration.options.glyphMarginClassName) {
const glyphClass = decoration.options.glyphMarginClassName;

if (glyphClass && !this.lightbulbClasses.some(className => glyphClass.includes(className))) {
hasDecoration = true;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
}

.monaco-workbench.linux:not(.web) .part.titlebar .window-controls-container.wco-enabled {
width: calc(var(--title-wco-width, 138px) / var(--zoom-factor, 1));
width: calc(var(--title-wco-width, 138px));
}

.monaco-workbench.linux:not(.web) .part.titlebar .titlebar-container.counter-zoom .window-controls-container.wco-enabled {
Expand Down
33 changes: 22 additions & 11 deletions code/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'vs/css!./media/titlebarpart';
import { localize, localize2 } from 'vs/nls';
import { MultiWindowParts, Part } from 'vs/workbench/browser/part';
import { ITitleService } from 'vs/workbench/services/title/browser/titleService';
import { getWCOTitlebarAreaRect, getZoomFactor, isWCOEnabled } from 'vs/base/browser/browser';
import { getWCOTitlebarAreaRect, getZoomFactor, isWCOEnabled, onDidChangeZoomLevel } from 'vs/base/browser/browser';
import { MenuBarVisibility, getTitleBarStyle, getMenuBarVisibility, TitlebarStyle, hasCustomTitlebar, hasNativeTitlebar, DEFAULT_CUSTOM_TITLEBAR_HEIGHT } from 'vs/platform/window/common/window';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
Expand Down Expand Up @@ -478,34 +478,45 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {

// Window Controls Container
if (!hasNativeTitlebar(this.configurationService, this.titleBarStyle)) {
let windowControlsLocation = isMacintosh ? 'left' : 'right';
let primaryWindowControlsLocation = isMacintosh ? 'left' : 'right';
if (isMacintosh && isNative) {

// Check if the locale is RTL, macOS will move traffic lights in RTL locales
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/textInfo

const localeInfo = new Intl.Locale(platformLocale) as any;
if (localeInfo?.textInfo?.direction === 'rtl') {
windowControlsLocation = 'right';
primaryWindowControlsLocation = 'right';
}
}

if (isMacintosh && isNative && windowControlsLocation === 'left') {
if (isMacintosh && isNative && primaryWindowControlsLocation === 'left') {
// macOS native: controls are on the left and the container is not needed to make room
// for something, except for web where a custom menu being supported). not putting the
// container helps with allowing to move the window when clicking very close to the
// window control buttons.
} else {
this.windowControlsContainer = append(windowControlsLocation === 'left' ? this.leftContent : this.rightContent, $('div.window-controls-container'));
this.windowControlsContainer = append(primaryWindowControlsLocation === 'left' ? this.leftContent : this.rightContent, $('div.window-controls-container'));
if (isWeb) {
// Web: its possible to have control overlays on both sides, for example on macOS
// with window controls on the left and PWA controls on the right.
append(primaryWindowControlsLocation === 'left' ? this.rightContent : this.leftContent, $('div.window-controls-container'));
}

if (isWCOEnabled()) {
this.windowControlsContainer.classList.add('wco-enabled');

const targetWindow = getWindow(this.element);
const wcoTitlebarAreaRect = getWCOTitlebarAreaRect(targetWindow);
if (wcoTitlebarAreaRect) {
const wcoWidth = targetWindow.innerWidth - wcoTitlebarAreaRect.width - wcoTitlebarAreaRect.x;
this.windowControlsContainer.style.setProperty('--title-wco-width', `${wcoWidth}px`);
}
const updateWCOWidthVariable = () => {
const targetWindow = getWindow(this.element);
const wcoTitlebarAreaRect = getWCOTitlebarAreaRect(targetWindow);
if (wcoTitlebarAreaRect) {
const wcoWidth = targetWindow.innerWidth - wcoTitlebarAreaRect.width - wcoTitlebarAreaRect.x;
this.windowControlsContainer?.style.setProperty('--title-wco-width', `${wcoWidth}px`);
}
};
updateWCOWidthVariable();

this._register(onDidChangeZoomLevel(() => setTimeout(() => updateWCOWidthVariable(), 5))); // Somehow it does not get the right size without this timeout :-/
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/src/vs/workbench/contrib/chat/browser/chatViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class ChatViewPane extends ViewPane {
}

override shouldShowWelcome(): boolean {
if (!this.chatAgentService.getDefaultAgent(ChatAgentLocation.Panel)) {
if (!this.chatAgentService.getContributedDefaultAgent(ChatAgentLocation.Panel)) {
return true;
}

Expand Down
1 change: 1 addition & 0 deletions code/src/vs/workbench/contrib/chat/common/chatAgents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export class ChatAgentService implements IChatAgentService {
};
const entry = { data };
this._agents.set(id, entry);
this._onDidChangeAgents.fire(undefined);
return toDisposable(() => {
this._agents.delete(id);
if (data.isDefault) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ function Set-MappedKeyHandler {

function Get-KeywordCompletionResult(
$Keyword,
$Description = $null
$Description = $Keyword
) {
[System.Management.Automation.CompletionResult]::new($Keyword, $Keyword, [System.Management.Automation.CompletionResultType]::Keyword, $null -ne $Description ? $Description : $Keyword)
[System.Management.Automation.CompletionResult]::new($Keyword, $Keyword, [System.Management.Automation.CompletionResultType]::Keyword, $Description)
}

function Set-MappedKeyHandlers {
Expand Down Expand Up @@ -360,7 +360,7 @@ function Send-Completions {
# completions are consistent regardless of where it was requested
elseif ($lastWord -match '[/\\]') {
$lastSlashIndex = $completionPrefix.LastIndexOfAny(@('/', '\'))
if ($lastSlashIndex -ne -1 && $lastSlashIndex -lt $cursorIndex) {
if ($lastSlashIndex -ne -1 -and $lastSlashIndex -lt $cursorIndex) {
$newCursorIndex = $lastSlashIndex + 1
$completionPrefix = $completionPrefix.Substring(0, $newCursorIndex)
$prefixCursorDelta = $cursorIndex - $newCursorIndex
Expand Down Expand Up @@ -430,7 +430,7 @@ function Send-Completions {
# completions are consistent regardless of where it was requested
if ($completionPrefix -match '[/\\]') {
$lastSlashIndex = $completionPrefix.LastIndexOfAny(@('/', '\'))
if ($lastSlashIndex -ne -1 && $lastSlashIndex -lt $cursorIndex) {
if ($lastSlashIndex -ne -1 -and $lastSlashIndex -lt $cursorIndex) {
$newCursorIndex = $lastSlashIndex + 1
$completionPrefix = $completionPrefix.Substring(0, $newCursorIndex)
$prefixCursorDelta = $cursorIndex - $newCursorIndex
Expand Down

0 comments on commit 954282f

Please sign in to comment.