提交 42a5c793 编写于 作者: A Alex Dima

Fixes #45146

上级 1fdf60b8
...@@ -14,6 +14,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; ...@@ -14,6 +14,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { showSimpleSuggestions } from 'vs/editor/contrib/suggest/suggest'; import { showSimpleSuggestions } from 'vs/editor/contrib/suggest/suggest';
import { ISuggestion } from 'vs/editor/common/modes'; import { ISuggestion } from 'vs/editor/common/modes';
import { Selection } from 'vs/editor/common/core/selection'; import { Selection } from 'vs/editor/common/core/selection';
import { Range } from 'vs/editor/common/core/range';
import { Choice } from 'vs/editor/contrib/snippet/snippetParser'; import { Choice } from 'vs/editor/contrib/snippet/snippetParser';
import { repeat } from 'vs/base/common/strings'; import { repeat } from 'vs/base/common/strings';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
...@@ -203,6 +204,13 @@ export class SnippetController2 implements IEditorContribution { ...@@ -203,6 +204,13 @@ export class SnippetController2 implements IEditorContribution {
this._session.next(); this._session.next();
this._updateState(); this._updateState();
} }
getSessionEnclosingRange(): Range {
if (this._session) {
return this._session.getEnclosingRange();
}
return undefined;
}
} }
......
...@@ -226,6 +226,20 @@ export class OneSnippet { ...@@ -226,6 +226,20 @@ export class OneSnippet {
this._placeholderGroups = groupBy(this._snippet.placeholders, Placeholder.compareByIndex); this._placeholderGroups = groupBy(this._snippet.placeholders, Placeholder.compareByIndex);
}); });
} }
public getEnclosingRange(): Range {
let result: Range;
const model = this._editor.getModel();
this._placeholderDecorations.forEach((decorationId) => {
const placeholderRange = model.getDecorationRange(decorationId);
if (!result) {
result = placeholderRange;
} else {
result = result.plusRange(placeholderRange);
}
});
return result;
}
} }
export class SnippetSession { export class SnippetSession {
...@@ -510,4 +524,17 @@ export class SnippetSession { ...@@ -510,4 +524,17 @@ export class SnippetSession {
// have any left, we don't have a selection anymore // have any left, we don't have a selection anymore
return allPossibleSelections.size > 0; return allPossibleSelections.size > 0;
} }
public getEnclosingRange(): Range {
let result: Range;
for (const snippet of this._snippets) {
const snippetRange = snippet.getEnclosingRange();
if (!result) {
result = snippetRange;
} else {
result = result.plusRange(snippetRange);
}
}
return result;
}
} }
...@@ -29,6 +29,7 @@ import { localize } from 'vs/nls'; ...@@ -29,6 +29,7 @@ import { localize } from 'vs/nls';
import { isFalsyOrEmpty } from 'vs/base/common/arrays'; import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { shouldSynchronizeModel } from 'vs/editor/common/services/modelService'; import { shouldSynchronizeModel } from 'vs/editor/common/services/modelService';
import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2';
export interface ISaveParticipantParticipant extends ISaveParticipant { export interface ISaveParticipantParticipant extends ISaveParticipant {
// progressMessage: string; // progressMessage: string;
...@@ -60,6 +61,12 @@ class TrimWhitespaceParticipant implements ISaveParticipantParticipant { ...@@ -60,6 +61,12 @@ class TrimWhitespaceParticipant implements ISaveParticipantParticipant {
prevSelection = editor.getSelections(); prevSelection = editor.getSelections();
if (isAutoSaved) { if (isAutoSaved) {
cursors.push(...prevSelection.map(s => new Position(s.positionLineNumber, s.positionColumn))); cursors.push(...prevSelection.map(s => new Position(s.positionLineNumber, s.positionColumn)));
const snippetsRange = SnippetController2.get(editor).getSessionEnclosingRange();
if (snippetsRange) {
for (let lineNumber = snippetsRange.startLineNumber; lineNumber <= snippetsRange.endLineNumber; lineNumber++) {
cursors.push(new Position(lineNumber, model.getLineMaxColumn(lineNumber)));
}
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册