Skip to content

Commit

Permalink
Rebase against the upstream 745cb55
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: 745cb55
  • Loading branch information
Eclipse Che Sync committed Dec 8, 2023
2 parents 9118c73 + 745cb55 commit 4c3b360
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 52 deletions.
42 changes: 28 additions & 14 deletions code/extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,24 @@ class BranchDeleteItem implements QuickPickItem {

class MergeItem implements QuickPickItem {

get label(): string { return this.ref.name || ''; }
get description(): string { return this.ref.name || ''; }
private shortCommit: string;

constructor(protected ref: Ref) { }
get label(): string {
return this.ref.type === RefType.RemoteHead ?
`$(cloud) ${this.ref.name ?? this.shortCommit}` :
`${this.repository.isBranchProtected(this.ref) ? '$(lock)' : '$(git-branch)'} ${this.ref.name ?? this.shortCommit}`;
}

async run(repository: Repository): Promise<void> {
await repository.merge(this.ref.name! || this.ref.commit!);
get description(): string {
return this.ref.type === RefType.RemoteHead ? l10n.t('Remote branch at {0}', this.shortCommit) : this.shortCommit;
}

constructor(private readonly repository: Repository, private readonly ref: Ref) {
this.shortCommit = (this.ref.commit ?? '').substring(0, 8);
}

async run(): Promise<void> {
await this.repository.merge(this.ref.name ?? this.ref.commit!);
}
}

Expand Down Expand Up @@ -2486,11 +2497,11 @@ export class CommandCenter {

const heads = refs.filter(ref => ref.type === RefType.Head)
.filter(ref => ref.name || ref.commit)
.map(ref => new MergeItem(ref as Branch));
.map(ref => new MergeItem(repository, ref as Branch));

const remoteHeads = (includeRemotes ? refs.filter(ref => ref.type === RefType.RemoteHead) : [])
.filter(ref => ref.name || ref.commit)
.map(ref => new MergeItem(ref as Branch));
.map(ref => new MergeItem(repository, ref as Branch));

return [...heads, ...remoteHeads];
};
Expand All @@ -2502,7 +2513,7 @@ export class CommandCenter {
return;
}

await choice.run(repository);
await choice.run();
}

@command('git.mergeAbort', { repository: true })
Expand Down Expand Up @@ -3264,18 +3275,21 @@ export class CommandCenter {
}

@command('git.stash', { repository: true })
async stash(repository: Repository): Promise<void> {
await this._stash(repository);
async stash(repository: Repository): Promise<boolean> {
const result = await this._stash(repository);
return result;
}

@command('git.stashStaged', { repository: true })
async stashStaged(repository: Repository): Promise<void> {
await this._stash(repository, false, true);
async stashStaged(repository: Repository): Promise<boolean> {
const result = await this._stash(repository, false, true);
return result;
}

@command('git.stashIncludeUntracked', { repository: true })
async stashIncludeUntracked(repository: Repository): Promise<void> {
await this._stash(repository, true);
async stashIncludeUntracked(repository: Repository): Promise<boolean> {
const result = await this._stash(repository, true);
return result;
}

@command('git.stashPop', { repository: true })
Expand Down
12 changes: 7 additions & 5 deletions code/src/vs/editor/browser/controller/pointerHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { BrowserFeatures } from 'vs/base/browser/canIUse';
import * as dom from 'vs/base/browser/dom';
import { EventType, Gesture, GestureEvent } from 'vs/base/browser/touch';
import { mainWindow } from 'vs/base/browser/window';
import { Disposable } from 'vs/base/common/lifecycle';
import * as platform from 'vs/base/common/platform';
import { IPointerHandlerHelper, MouseHandler } from 'vs/editor/browser/controller/mouseHandler';
import { TextAreaSyntethicEvents } from 'vs/editor/browser/controller/textAreaInput';
import { NavigationCommandRevealType } from 'vs/editor/browser/coreCommands';
import { IMouseTarget, MouseTargetType } from 'vs/editor/browser/editorBrowser';
import { EditorMouseEvent, EditorPointerEventFactory } from 'vs/editor/browser/editorDom';
import { ViewController } from 'vs/editor/browser/view/viewController';
import { ViewContext } from 'vs/editor/common/viewModel/viewContext';
import { BrowserFeatures } from 'vs/base/browser/canIUse';
import { TextAreaSyntethicEvents } from 'vs/editor/browser/controller/textAreaInput';
import { NavigationCommandRevealType } from 'vs/editor/browser/coreCommands';
import { mainWindow } from 'vs/base/browser/window';

/**
* Currently only tested on iOS 13/ iPadOS.
Expand Down Expand Up @@ -140,7 +141,8 @@ export class PointerHandler extends Disposable {

constructor(context: ViewContext, viewController: ViewController, viewHelper: IPointerHandlerHelper) {
super();
if (BrowserFeatures.pointerEvents) {
const isPhone = platform.isIOS || (platform.isAndroid && platform.isMobile);
if (isPhone && BrowserFeatures.pointerEvents) {
this.handler = this._register(new PointerEventHandler(context, viewController, viewHelper));
} else if (mainWindow.TouchEvent) {
this.handler = this._register(new TouchHandler(context, viewController, viewHelper));
Expand Down
2 changes: 1 addition & 1 deletion code/src/vs/editor/browser/editorExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export abstract class Command {
/**
* Potential override for a command.
*
* @return `true` if the command was successfully run. This stops other overrides from being executed.
* @return `true` or a Promise if the command was successfully run. This stops other overrides from being executed.
*/
export type CommandImplementation = (accessor: ServicesAccessor, args: unknown) => boolean | Promise<void>;

Expand Down
2 changes: 1 addition & 1 deletion code/src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ export class EditorFontLigatures extends BaseEditorOption<EditorOption.fontLigat
return this.defaultValue;
}
if (typeof input === 'string') {
if (input === 'false') {
if (input === 'false' || input.length === 0) {
return EditorFontLigatures.OFF;
}
if (input === 'true') {
Expand Down
7 changes: 5 additions & 2 deletions code/src/vs/editor/contrib/clipboard/browser/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { Handler } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { CopyPasteController } from 'vs/editor/contrib/dropOrPasteInto/browser/copyPasteController';
import * as nls from 'vs/nls';
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
Expand Down Expand Up @@ -227,8 +228,10 @@ if (PasteAction) {
const focusedEditor = codeEditorService.getFocusedCodeEditor();
if (focusedEditor && focusedEditor.hasTextFocus()) {
const result = focusedEditor.getContainerDomNode().ownerDocument.execCommand('paste');
// Use the clipboard service if document.execCommand('paste') was not successful
if (!result && platform.isWeb) {
if (result) {
return CopyPasteController.get(focusedEditor).finishedPaste();
} else if (platform.isWeb) {
// Use the clipboard service if document.execCommand('paste') was not successful
return (async () => {
const clipboardText = await clipboardService.readText();
if (clipboardText !== '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export class CopyPasteController extends Disposable implements IEditorContributi
&& !this._editor.getOption(EditorOption.readOnly);
}

public async finishedPaste(): Promise<void> {
await this._currentPasteOperation;
}

private handleCopy(e: ClipboardEvent) {
if (!this._editor.hasTextFocus()) {
return;
Expand Down
4 changes: 0 additions & 4 deletions code/src/vs/editor/contrib/hover/browser/contentHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,10 +911,6 @@ export class ContentHoverWidget extends ResizableContentWidget {
public goToBottom(): void {
this._hover.scrollbar.setScrollPosition({ scrollTop: this._hover.scrollbar.getScrollDimensions().scrollHeight });
}

public toggleLocked(locked: boolean): void {
this._hover.containerDomNode.classList.toggle('locked', locked);
}
}

export class EditorHoverStatusBar extends Disposable implements IEditorHoverStatusBar {
Expand Down
4 changes: 0 additions & 4 deletions code/src/vs/editor/contrib/hover/browser/hover.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
border-radius: 3px;
}

.monaco-editor .monaco-hover.locked {
outline: 1px solid var(--vscode-editorHoverWidget-border);
}

.monaco-editor .monaco-hover a {
color: var(--vscode-textLink-foreground);
}
Expand Down
19 changes: 0 additions & 19 deletions code/src/vs/editor/contrib/hover/browser/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ interface IHoverSettings {

interface IHoverState {
mouseDown: boolean;
locked: boolean;
// TODO @aiday-mar maybe not needed, investigate this
contentHoverFocused: boolean;
activatedByDecoratorClick: boolean;
Expand All @@ -67,7 +66,6 @@ export class HoverController extends Disposable implements IEditorContribution {
private _hoverSettings!: IHoverSettings;
private _hoverState: IHoverState = {
mouseDown: false,
locked: false,
contentHoverFocused: false,
activatedByDecoratorClick: false
};
Expand Down Expand Up @@ -112,7 +110,6 @@ export class HoverController extends Disposable implements IEditorContribution {
this._listenersStore.add(this._editor.onMouseUp(() => this._onEditorMouseUp()));
this._listenersStore.add(this._editor.onMouseMove((e: IEditorMouseEvent) => this._onEditorMouseMove(e)));
this._listenersStore.add(this._editor.onKeyDown((e: IKeyboardEvent) => this._onKeyDown(e)));
this._listenersStore.add(this._editor.onKeyUp((e: IKeyboardEvent) => this._onKeyUp(e)));
} else {
this._listenersStore.add(this._editor.onMouseMove((e: IEditorMouseEvent) => this._onEditorMouseMove(e)));
this._listenersStore.add(this._editor.onKeyDown((e: IKeyboardEvent) => this._onKeyDown(e)));
Expand Down Expand Up @@ -232,10 +229,6 @@ export class HoverController extends Disposable implements IEditorContribution {
private _onEditorMouseMove(mouseEvent: IEditorMouseEvent): void {

this._mouseMoveEvent = mouseEvent;
if (this._hoverState.locked) {
// When the alt key is pressed, hover remains visible
return;
}
if (this._contentWidget?.isFocused || this._contentWidget?.isResizing) {
return;
}
Expand Down Expand Up @@ -319,7 +312,6 @@ export class HoverController extends Disposable implements IEditorContribution {
if (!this._editor.hasModel()) {
return;
}
this._toggleLockedState(e.altKey);

const resolvedKeyboardEvent = this._keybindingService.softDispatch(e, this._editor.getDomNode());

Expand Down Expand Up @@ -348,17 +340,6 @@ export class HoverController extends Disposable implements IEditorContribution {
this._hideWidgets();
}

private _onKeyUp(e: IKeyboardEvent): void {
this._toggleLockedState(!e.altKey);
}

private _toggleLockedState(locked: boolean) {
if (this._hoverState.locked !== locked) {
this._hoverState.locked = locked;
this._contentWidget?.widget.toggleLocked(this._hoverState.locked);
}
}

private _hideWidgets(): void {
if (_sticky) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,14 @@ export class LiveStrategy extends EditModeStrategy {
}

private static _undoModelUntil(model: ITextModel, targetAltVersion: number): void {
while (targetAltVersion < model.getAlternativeVersionId() && model.canUndo()) {
let actualAltVersion = model.getAlternativeVersionId();
while (targetAltVersion < actualAltVersion && model.canUndo()) {
model.undo();
const newActualAltVersion = model.getAlternativeVersionId();
if (actualAltVersion === newActualAltVersion) {
break;
}
actualAltVersion = newActualAltVersion;
}
}

Expand Down Expand Up @@ -955,8 +961,14 @@ export class LiveStrategy3 extends EditModeStrategy {
}

private static _undoModelUntil(model: ITextModel, targetAltVersion: number): void {
while (targetAltVersion < model.getAlternativeVersionId() && model.canUndo()) {
let actualAltVersion = model.getAlternativeVersionId();
while (targetAltVersion < actualAltVersion && model.canUndo()) {
model.undo();
const newActualAltVersion = model.getAlternativeVersionId();
if (actualAltVersion === newActualAltVersion) {
break;
}
actualAltVersion = newActualAltVersion;
}
}

Expand Down

0 comments on commit 4c3b360

Please sign in to comment.