Skip to content

Commit

Permalink
debug repl: history next and previous only enable on last and first line
Browse files Browse the repository at this point in the history
fixes #11245
  • Loading branch information
isidorn committed Aug 31, 2016
1 parent 2f8e7a9 commit 77d3fe3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/vs/workbench/parts/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const CONTEXT_IN_DEBUG_MODE = new RawContextKey<boolean>('inDebugMode', f
export const CONTEXT_NOT_IN_DEBUG_MODE: ContextKeyExpr = CONTEXT_IN_DEBUG_MODE.toNegated();
export const CONTEXT_IN_DEBUG_REPL = new RawContextKey<boolean>('inDebugRepl', false);
export const CONTEXT_NOT_IN_DEBUG_REPL: ContextKeyExpr = CONTEXT_IN_DEBUG_REPL.toNegated();
export const CONTEXT_ON_FIRST_DEBUG_REPL_LINE = new RawContextKey<boolean>('onFirsteDebugReplLine', false);
export const CONTEXT_ON_LAST_DEBUG_REPL_LINE = new RawContextKey<boolean>('onLastDebugReplLine', false);
export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug';
export const DEBUG_SCHEME = 'debug';

Expand Down
14 changes: 11 additions & 3 deletions src/vs/workbench/parts/debug/electron-browser/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ export class Repl extends Panel implements IPrivateReplService {
const scopedContextKeyService = this.contextKeyService.createScoped(this.replInputContainer);
this.toDispose.push(scopedContextKeyService);
debug.CONTEXT_IN_DEBUG_REPL.bindTo(scopedContextKeyService).set(true);
const onFirstReplLine = debug.CONTEXT_ON_FIRST_DEBUG_REPL_LINE.bindTo(scopedContextKeyService);
onFirstReplLine.set(true);
const onLastReplLine = debug.CONTEXT_ON_LAST_DEBUG_REPL_LINE.bindTo(scopedContextKeyService);
onLastReplLine.set(true);

const scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection(
[IContextKeyService, scopedContextKeyService], [IPrivateReplService, this]));

this.replInput = scopedInstantiationService.createInstance(CodeEditor, this.replInputContainer, this.getReplInputOptions());
const model = this.modelService.createModel('', null, uri.parse(`${debug.DEBUG_SCHEME}:input`));
this.replInput.setModel(model);
Expand All @@ -174,6 +178,10 @@ export class Repl extends Panel implements IPrivateReplService {
}
this.layout(this.dimension, Math.min(170, e.scrollHeight));
}));
this.toDispose.push(this.replInput.onDidChangeCursorPosition(e => {
onFirstReplLine.set(e.position.lineNumber === 1);
onLastReplLine.set(e.position.lineNumber === this.replInput.getModel().getLineCount());
}));

this.toDispose.push(dom.addStandardDisposableListener(this.replInputContainer, dom.EventType.FOCUS, () => dom.addClass(this.replInputContainer, 'synthetic-focus')));
this.toDispose.push(dom.addStandardDisposableListener(this.replInputContainer, dom.EventType.BLUR, () => dom.removeClass(this.replInputContainer, 'synthetic-focus')));
Expand Down Expand Up @@ -289,7 +297,7 @@ class ReplHistoryPreviousAction extends EditorAction {
id: 'repl.action.historyPrevious',
label: nls.localize('actions.repl.historyPrevious', "History Previous"),
alias: 'History Previous',
precondition: debug.CONTEXT_IN_DEBUG_REPL,
precondition: debug.CONTEXT_ON_FIRST_DEBUG_REPL_LINE,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.UpArrow,
Expand All @@ -314,7 +322,7 @@ class ReplHistoryNextAction extends EditorAction {
id: 'repl.action.historyNext',
label: nls.localize('actions.repl.historyNext', "History Next"),
alias: 'History Next',
precondition: debug.CONTEXT_IN_DEBUG_REPL,
precondition: debug.CONTEXT_ON_LAST_DEBUG_REPL_LINE,
kbOpts: {
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.DownArrow,
Expand Down

0 comments on commit 77d3fe3

Please sign in to comment.