提交 349c9b9b 编写于 作者: I isidor

Check if there are more characters on a line after a "configurations": [, if yes enter a newline

fixes #22624
上级 fa2e9d17
......@@ -19,10 +19,9 @@ import { StandardTokenType } from 'vs/editor/common/modes';
import { DEFAULT_WORD_REGEXP } from 'vs/editor/common/model/wordHelper';
import { ICodeEditor, IEditorMouseEvent } from 'vs/editor/browser/editorBrowser';
import { editorContribution } from 'vs/editor/browser/editorBrowserExtensions';
import { IDecorationOptions, IModelDecorationOptions, MouseTargetType, IModelDeltaDecoration, TrackedRangeStickiness, IPosition } from 'vs/editor/common/editorCommon';
import { IDecorationOptions, IModelDecorationOptions, MouseTargetType, IModelDeltaDecoration, TrackedRangeStickiness, IPosition, Handler } from 'vs/editor/common/editorCommon';
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
......@@ -396,7 +395,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
public addLaunchConfiguration(): TPromise<any> {
this.telemetryService.publicLog('debug/addLaunchConfiguration');
let configurationsPosition: IPosition;
let configurationsArrayPosition: IPosition;
const model = this.editor.getModel();
let depthInArray = 0;
let lastProperty: string;
......@@ -407,7 +406,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
},
onArrayBegin: (offset: number, length: number) => {
if (lastProperty === 'configurations' && depthInArray === 0) {
configurationsPosition = model.getPositionAt(offset);
configurationsArrayPosition = model.getPositionAt(offset + 1);
}
depthInArray++;
},
......@@ -417,21 +416,27 @@ export class DebugEditorContribution implements IDebugEditorContribution {
});
this.editor.focus();
if (!configurationsPosition) {
if (!configurationsArrayPosition) {
return this.commandService.executeCommand('editor.action.triggerSuggest');
}
const insertLineAfter = (lineNumber: number): TPromise<any> => {
if (this.editor.getModel().getLineLastNonWhitespaceColumn(lineNumber + 1) === 0) {
this.editor.setSelection(new Selection(lineNumber + 1, Number.MAX_VALUE, lineNumber + 1, Number.MAX_VALUE));
const insertLine = (position: IPosition): TPromise<any> => {
// Check if there are more characters on a line after a "configurations": [, if yes enter a newline
if (this.editor.getModel().getLineLastNonWhitespaceColumn(position.lineNumber) > position.column) {
this.editor.setPosition(position);
this.editor.trigger(this.getId(), Handler.LineBreakInsert, undefined);
}
// Check if there is already an empty line to insert suggest, if yes just place the cursor
if (this.editor.getModel().getLineLastNonWhitespaceColumn(position.lineNumber + 1) === 0) {
this.editor.setPosition({ lineNumber: position.lineNumber + 1, column: Constants.MAX_SAFE_SMALL_INTEGER });
return TPromise.as(null);
}
this.editor.setSelection(new Selection(lineNumber, Number.MAX_VALUE, lineNumber, Number.MAX_VALUE));
this.editor.setPosition(position);
return this.commandService.executeCommand('editor.action.insertLineAfter');
};
return insertLineAfter(configurationsPosition.lineNumber).then(() => this.commandService.executeCommand('editor.action.triggerSuggest'));
return insertLine(configurationsArrayPosition).then(() => this.commandService.executeCommand('editor.action.triggerSuggest'));
}
private static BREAKPOINT_HELPER_DECORATION: IModelDecorationOptions = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册