Add Markdown Preview to Editor Scroll Syncronization

Adds an initial implementation of scroll synrconization from the markdown preview to the editor. When the preview is scrolled, automatically scrolls the editor to reveal the same location.

This required adding a new supported reveal type `AtTop` in our API. This is already supported and used internally, but not really exposed in the public apis (except for the `revealLine` command).
This commit is contained in:
Matt Bierner
2017-01-21 18:03:05 -08:00
parent 8f76900a67
commit 5bf8cc7618
11 changed files with 85 additions and 26 deletions

View File

@@ -56,7 +56,8 @@ export interface IFocusTracker {
export enum TextEditorRevealType {
Default = 0,
InCenter = 1,
InCenterIfOutsideViewport = 2
InCenterIfOutsideViewport = 2,
AtTop = 3
}
export interface IUndoStopOptions {
@@ -288,14 +289,22 @@ export class MainThreadTextEditor {
console.warn('revealRange on invisible editor');
return;
}
if (revealType === TextEditorRevealType.Default) {
this._codeEditor.revealRange(range);
} else if (revealType === TextEditorRevealType.InCenter) {
this._codeEditor.revealRangeInCenter(range);
} else if (revealType === TextEditorRevealType.InCenterIfOutsideViewport) {
this._codeEditor.revealRangeInCenterIfOutsideViewport(range);
} else {
console.warn('Unknown revealType');
switch (revealType) {
case TextEditorRevealType.Default:
this._codeEditor.revealRange(range);
break;
case TextEditorRevealType.InCenter:
this._codeEditor.revealRangeInCenter(range);
break;;
case TextEditorRevealType.InCenterIfOutsideViewport:
this._codeEditor.revealRangeInCenterIfOutsideViewport(range);
break;
case TextEditorRevealType.AtTop:
this._codeEditor.revealRangeAtTop(range);
break;
default:
console.warn('Unknown revealType');
break;
}
}