@@ -22883,6 +22883,33 @@ var require_framework = __commonJS({
22883
22883
var require_assist = __commonJS({
22884
22884
"out/assist.js"(exports2) {
22885
22885
"use strict";
22886
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
22887
+ function adopt(value) {
22888
+ return value instanceof P ? value : new P(function(resolve) {
22889
+ resolve(value);
22890
+ });
22891
+ }
22892
+ return new (P || (P = Promise))(function(resolve, reject) {
22893
+ function fulfilled(value) {
22894
+ try {
22895
+ step(generator.next(value));
22896
+ } catch (e) {
22897
+ reject(e);
22898
+ }
22899
+ }
22900
+ function rejected(value) {
22901
+ try {
22902
+ step(generator["throw"](value));
22903
+ } catch (e) {
22904
+ reject(e);
22905
+ }
22906
+ }
22907
+ function step(result) {
22908
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
22909
+ }
22910
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22911
+ });
22912
+ };
22886
22913
Object.defineProperty(exports2, "__esModule", { value: true });
22887
22914
var vscode_12 = require("vscode");
22888
22915
var Assist = class {
@@ -22896,6 +22923,105 @@ var require_assist = __commonJS({
22896
22923
this.explorer.context.subscriptions.push(vscode_12.commands.registerCommand("vue-helper.funcEnhance", () => {
22897
22924
this.funcEnhance();
22898
22925
}));
22926
+ this.explorer.context.subscriptions.push(vscode_12.commands.registerCommand("vue-helper.backspace", () => {
22927
+ this.backspce();
22928
+ }));
22929
+ }
22930
+ asNormal(key, modifiers) {
22931
+ switch (key) {
22932
+ case "enter":
22933
+ if (modifiers === "ctrl") {
22934
+ return vscode_12.commands.executeCommand("editor.action.insertLineAfter");
22935
+ } else {
22936
+ return vscode_12.commands.executeCommand("type", { source: "keyboard", text: "\n" });
22937
+ }
22938
+ case "tab":
22939
+ if (vscode_12.workspace.getConfiguration("emmet").get("triggerExpansionOnTab")) {
22940
+ return vscode_12.commands.executeCommand("editor.emmet.action.expandAbbreviation");
22941
+ } else if (modifiers === "shift") {
22942
+ return vscode_12.commands.executeCommand("editor.action.outdentLines");
22943
+ } else {
22944
+ return vscode_12.commands.executeCommand("tab");
22945
+ }
22946
+ case "backspace":
22947
+ return vscode_12.commands.executeCommand("deleteLeft");
22948
+ }
22949
+ }
22950
+ backspce() {
22951
+ var _a, _b, _c, _d, _e, _f, _g;
22952
+ return __awaiter(this, void 0, void 0, function* () {
22953
+ let editor = vscode_12.window.activeTextEditor;
22954
+ if (!editor) {
22955
+ this.asNormal("backspace");
22956
+ return;
22957
+ }
22958
+ if (((_a = vscode_12.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.selections.length) && ((_b = vscode_12.window.activeTextEditor) === null || _b === void 0 ? void 0 : _b.selections.length) > 1) {
22959
+ let selections = (_c = vscode_12.window.activeTextEditor) === null || _c === void 0 ? void 0 : _c.selections;
22960
+ let selectionList = [];
22961
+ for (let index = 0; index < selections.length; index++) {
22962
+ const selection = selections[index];
22963
+ if (selection.start.line === selection.end.line && selection.start.character === selection.end.character) {
22964
+ if (selection.anchor.character > 0) {
22965
+ selectionList.push(new vscode_12.Selection(new vscode_12.Position(selection.anchor.line, selection.anchor.character - 1), selection.anchor));
22966
+ } else if (selection.anchor.line > 0) {
22967
+ let len = editor.document.lineAt(selection.anchor.line - 1).text.length;
22968
+ selectionList.push(new vscode_12.Selection(new vscode_12.Position(selection.anchor.line - 1, len), selection.anchor));
22969
+ }
22970
+ } else {
22971
+ selectionList.push(selection);
22972
+ }
22973
+ }
22974
+ yield editor.edit((editBuilder) => {
22975
+ for (let i = 0; i < selectionList.length; i++) {
22976
+ editBuilder.delete(selectionList[i]);
22977
+ }
22978
+ });
22979
+ return;
22980
+ }
22981
+ if (((_d = vscode_12.window.activeTextEditor) === null || _d === void 0 ? void 0 : _d.selection.start.line) === ((_e = vscode_12.window.activeTextEditor) === null || _e === void 0 ? void 0 : _e.selection.end.line) && ((_f = vscode_12.window.activeTextEditor) === null || _f === void 0 ? void 0 : _f.selection.start.character) === ((_g = vscode_12.window.activeTextEditor) === null || _g === void 0 ? void 0 : _g.selection.end.character)) {
22982
+ if (editor.selection.anchor.line === 0) {
22983
+ if (editor.selection.anchor.character > 0) {
22984
+ yield editor.edit((editBuilder) => {
22985
+ editBuilder.delete(new vscode_12.Selection(new vscode_12.Position(editor.selection.anchor.line, editor.selection.anchor.character - 1), editor.selection.anchor));
22986
+ });
22987
+ }
22988
+ } else {
22989
+ let isLineEmpty = editor.document.lineAt(editor.selection.anchor.line).text.trim() === "";
22990
+ if (isLineEmpty) {
22991
+ let preText = "";
22992
+ let line = editor.selection.anchor.line;
22993
+ while (preText.trim() === "" && line >= 0) {
22994
+ line -= 1;
22995
+ preText = editor.document.lineAt(line).text;
22996
+ }
22997
+ yield editor.edit((editBuilder) => {
22998
+ editBuilder.delete(new vscode_12.Selection(new vscode_12.Position(line, preText.length), editor.selection.anchor));
22999
+ });
23000
+ } else {
23001
+ let startPosition;
23002
+ let endPosition = editor.selection.anchor;
23003
+ let preLineText = editor.document.getText(new vscode_12.Range(new vscode_12.Position(endPosition.line, 0), endPosition));
23004
+ if (endPosition.character === 0 || preLineText.trim() === "") {
23005
+ startPosition = new vscode_12.Position(endPosition.line - 1, editor.document.lineAt(endPosition.line - 1).text.length);
23006
+ } else {
23007
+ startPosition = new vscode_12.Position(endPosition.line, endPosition.character - 1);
23008
+ let txt = editor.document.getText(new vscode_12.Range(new vscode_12.Position(endPosition.line, endPosition.character - 1), endPosition));
23009
+ if (editor.document.lineAt(endPosition.line).text.length > endPosition.character) {
23010
+ let nextTxt = editor.document.getText(new vscode_12.Range(endPosition, new vscode_12.Position(endPosition.line, endPosition.character + 1)));
23011
+ if (txt === "{" && nextTxt === "}" || txt === "(" && nextTxt === ")" || txt === "'" && nextTxt === "'" || txt === '"' && nextTxt === '"' || txt === "[" && nextTxt === "]" || txt === "<" && nextTxt === ">") {
23012
+ endPosition = new vscode_12.Position(endPosition.line, endPosition.character + 1);
23013
+ }
23014
+ }
23015
+ }
23016
+ yield editor.edit((editBuilder) => {
23017
+ editBuilder.delete(new vscode_12.Selection(startPosition, endPosition));
23018
+ });
23019
+ }
23020
+ }
23021
+ } else {
23022
+ this.asNormal("backspace");
23023
+ }
23024
+ });
22899
23025
}
22900
23026
funcEnhance() {
22901
23027
var _a, _b, _c, _d;
0 commit comments