mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
mirror 'source' when cursor changes, #8093
This commit is contained in:
@@ -29,7 +29,7 @@ import {IResourceEdit} from 'vs/editor/common/services/bulkEdit';
|
||||
|
||||
import {IPickOpenEntry, IPickOptions} from 'vs/workbench/services/quickopen/common/quickOpenService';
|
||||
import {ITypeBearing} from 'vs/workbench/parts/search/common/search';
|
||||
import {TextEditorRevealType, ITextEditorConfigurationUpdate, IResolvedTextEditorConfiguration} from './mainThreadEditorsTracker';
|
||||
import {TextEditorRevealType, ITextEditorConfigurationUpdate, IResolvedTextEditorConfiguration, ISelectionChangeEvent} from './mainThreadEditorsTracker';
|
||||
import {EndOfLine} from './extHostTypes';
|
||||
|
||||
export interface InstanceSetter<T> {
|
||||
@@ -230,7 +230,7 @@ export interface ITextEditorPositionData {
|
||||
export abstract class ExtHostEditorsShape {
|
||||
$acceptTextEditorAdd(data: ITextEditorAddData): void { throw ni(); }
|
||||
$acceptOptionsChanged(id: string, opts: IResolvedTextEditorConfiguration): void { throw ni(); }
|
||||
$acceptSelectionsChanged(id: string, _selections: editorCommon.ISelection[]): void { throw ni(); }
|
||||
$acceptSelectionsChanged(id: string, event: ISelectionChangeEvent): void { throw ni(); }
|
||||
$acceptActiveEditorAndVisibleEditors(id: string, visibleIds: string[]): void { throw ni(); }
|
||||
$acceptEditorPositionData(data: ITextEditorPositionData): void { throw ni(); }
|
||||
$acceptTextEditorRemove(id: string): void { throw ni(); }
|
||||
|
||||
@@ -12,8 +12,8 @@ import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
|
||||
import {ExtHostDocuments, ExtHostDocumentData} from 'vs/workbench/api/node/extHostDocuments';
|
||||
import {Selection, Range, Position, EditorOptions, EndOfLine, TextEditorRevealType} from './extHostTypes';
|
||||
import {ISingleEditOperation, ISelection} from 'vs/editor/common/editorCommon';
|
||||
import {IResolvedTextEditorConfiguration} from 'vs/workbench/api/node/mainThreadEditorsTracker';
|
||||
import {ISingleEditOperation} from 'vs/editor/common/editorCommon';
|
||||
import {IResolvedTextEditorConfiguration, ISelectionChangeEvent} from 'vs/workbench/api/node/mainThreadEditorsTracker';
|
||||
import * as TypeConverters from './extHostTypeConverters';
|
||||
import {TextDocument, TextEditorSelectionChangeEvent, TextEditorOptionsChangeEvent, TextEditorOptions, TextEditorViewColumnChangeEvent, ViewColumn} from 'vscode';
|
||||
import {MainContext, MainThreadEditorsShape, ExtHostEditorsShape, ITextEditorAddData, ITextEditorPositionData} from './extHost.protocol';
|
||||
@@ -102,8 +102,8 @@ export class ExtHostEditors extends ExtHostEditorsShape {
|
||||
});
|
||||
}
|
||||
|
||||
$acceptSelectionsChanged(id: string, _selections: ISelection[]): void {
|
||||
let selections = _selections.map(TypeConverters.toSelection);
|
||||
$acceptSelectionsChanged(id: string, event: ISelectionChangeEvent): void {
|
||||
let selections = event.selections.map(TypeConverters.toSelection);
|
||||
let editor = this._editors[id];
|
||||
editor._acceptSelections(selections);
|
||||
this._onDidChangeTextEditorSelection.fire({
|
||||
|
||||
@@ -81,8 +81,8 @@ export class MainThreadEditors extends MainThreadEditorsShape {
|
||||
toDispose.push(textEditor.onConfigurationChanged((opts) => {
|
||||
this._proxy.$acceptOptionsChanged(id, opts);
|
||||
}));
|
||||
toDispose.push(textEditor.onSelectionChanged((selection) => {
|
||||
this._proxy.$acceptSelectionsChanged(id, selection);
|
||||
toDispose.push(textEditor.onSelectionChanged((event) => {
|
||||
this._proxy.$acceptSelectionsChanged(id, event);
|
||||
}));
|
||||
this._proxy.$acceptTextEditorAdd({
|
||||
id: id,
|
||||
|
||||
@@ -40,6 +40,11 @@ function configurationsEqual(a:IResolvedTextEditorConfiguration, b:IResolvedText
|
||||
);
|
||||
}
|
||||
|
||||
export interface ISelectionChangeEvent {
|
||||
selections: Selection[];
|
||||
source?: string;
|
||||
}
|
||||
|
||||
export interface IFocusTracker {
|
||||
onGainedFocus(): void;
|
||||
onLostFocus(): void;
|
||||
@@ -68,7 +73,7 @@ export class MainThreadTextEditor {
|
||||
private _lastSelection: Selection[];
|
||||
private _configuration: IResolvedTextEditorConfiguration;
|
||||
|
||||
private _onSelectionChanged: Emitter<Selection[]>;
|
||||
private _onSelectionChanged: Emitter<ISelectionChangeEvent>;
|
||||
private _onConfigurationChanged: Emitter<IResolvedTextEditorConfiguration>;
|
||||
|
||||
constructor(
|
||||
@@ -85,7 +90,7 @@ export class MainThreadTextEditor {
|
||||
this._modelService = modelService;
|
||||
this._codeEditorListeners = [];
|
||||
|
||||
this._onSelectionChanged = new Emitter<Selection[]>();
|
||||
this._onSelectionChanged = new Emitter<ISelectionChangeEvent>();
|
||||
this._onConfigurationChanged = new Emitter<IResolvedTextEditorConfiguration>();
|
||||
|
||||
this._lastSelection = [ new Selection(1,1,1,1) ];
|
||||
@@ -132,9 +137,12 @@ export class MainThreadTextEditor {
|
||||
this.setCodeEditor(null);
|
||||
}));
|
||||
|
||||
let forwardSelection = () => {
|
||||
let forwardSelection = (event?: EditorCommon.ICursorSelectionChangedEvent) => {
|
||||
this._lastSelection = this._codeEditor.getSelections();
|
||||
this._onSelectionChanged.fire(this._lastSelection);
|
||||
this._onSelectionChanged.fire({
|
||||
selections: this._lastSelection,
|
||||
source: event && event.source
|
||||
});
|
||||
};
|
||||
this._codeEditorListeners.push(this._codeEditor.onDidChangeCursorSelection(forwardSelection));
|
||||
if (!Selection.selectionsArrEqual(this._lastSelection, this._codeEditor.getSelections())) {
|
||||
@@ -157,7 +165,7 @@ export class MainThreadTextEditor {
|
||||
return !!this._codeEditor;
|
||||
}
|
||||
|
||||
public get onSelectionChanged(): Event<Selection[]> {
|
||||
public get onSelectionChanged(): Event<ISelectionChangeEvent> {
|
||||
return this._onSelectionChanged.event;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user