Skip to content

Commit df300fe

Browse files
committed
Revert "Allows editing of start/end tag simultaneously"
Fixes #601 This reverts commit 9f32fc1.
1 parent 6c41189 commit df300fe

File tree

3 files changed

+10
-348
lines changed

3 files changed

+10
-348
lines changed

package.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,6 @@
193193
"description": "Enable/disable autoclosing of XML tags. \n\nIMPORTANT: Turn off editor.autoClosingTags for this to work",
194194
"scope": "window"
195195
},
196-
"xml.mirrorCursorOnMatchingTag": {
197-
"type": "boolean",
198-
"scope": "resource",
199-
"default": false,
200-
"description": "Adds an additional cursor on the matching tag, allows for start/end tag editing."
201-
},
202196
"xml.codeLens.enabled": {
203197
"type": "boolean",
204198
"default": false,
@@ -301,14 +295,6 @@
301295
"fileMatch": "package.json",
302296
"url": "./schemas/package.schema.json"
303297
}
304-
],
305-
"keybindings":[
306-
{
307-
"command": "xml.toggleMatchingTagEdit",
308-
"key": "ctrl+shift+f2",
309-
"mac": "cmd+shift+f2",
310-
"when": "editorFocus"
311-
}
312298
]
313299
}
314300
}

src/extension.ts

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,24 @@
1313
import { prepareExecutable } from './javaServerStarter';
1414
import { LanguageClientOptions, RevealOutputChannelOn, LanguageClient, DidChangeConfigurationNotification, RequestType, TextDocumentPositionParams, ReferencesRequest } from 'vscode-languageclient';
1515
import * as requirements from './requirements';
16-
import { languages, ConfigurationTarget, IndentAction, workspace, window, commands, ExtensionContext, TextDocument, Position, LanguageConfiguration, Uri, WorkspaceConfiguration, extensions } from "vscode";
16+
import { languages, IndentAction, workspace, window, commands, ExtensionContext, TextDocument, Position, LanguageConfiguration, Uri, extensions } from "vscode";
1717
import * as path from 'path';
1818
import * as os from 'os';
1919
import { activateTagClosing, AutoCloseResult } from './tagClosing';
2020
import { Commands } from './commands';
2121
import { onConfigurationChange, subscribeJDKChangeConfiguration } from './settings';
2222
import { collectXmlJavaExtensions, onExtensionChange } from './plugin';
23-
import { activateMirrorCursor } from './mirrorCursor';
2423

2524
export interface ScopeInfo {
26-
scope: "default" | "global" | "workspace" | "folder";
25+
scope : "default" | "global" | "workspace" | "folder";
2726
configurationTarget: boolean;
2827
}
2928

3029
namespace TagCloseRequest {
3130
export const type: RequestType<TextDocumentPositionParams, AutoCloseResult, any, any> = new RequestType('xml/closeTag');
3231
}
3332

34-
namespace MatchingTagPositionRequest {
35-
export const type: RequestType<TextDocumentPositionParams, Position | null, any, any> = new RequestType('xml/matchingTagPosition');
36-
}
33+
3734

3835
export function activate(context: ExtensionContext) {
3936
let storagePath = context.storagePath;
@@ -73,7 +70,7 @@ export function activate(context: ExtensionContext) {
7370
}
7471
}
7572
}
76-
},
73+
},
7774
synchronize: {
7875
//preferences starting with these will trigger didChangeConfiguration
7976
configurationSection: ['xml', '[xml]']
@@ -117,38 +114,14 @@ export function activate(context: ExtensionContext) {
117114
return text;
118115
};
119116

120-
disposable = activateTagClosing(tagProvider, { xml: true, xsl: true }, Commands.AUTO_CLOSE_TAGS);
121-
toDispose.push(disposable);
122-
123-
//Setup mirrored tag rename request
124-
const matchingTagPositionRequestor = (document: TextDocument, position: Position) => {
125-
let param = languageClient.code2ProtocolConverter.asTextDocumentPositionParams(document, position);
126-
return languageClient.sendRequest(MatchingTagPositionRequest.type, param);
127-
};
128-
129-
disposable = activateMirrorCursor(context, matchingTagPositionRequestor, { xml: true }, 'xml.mirrorCursorOnMatchingTag');
130-
toDispose.push(disposable);
131-
132-
const matchingTagEditCommand = 'xml.toggleMatchingTagEdit';
133-
134-
const matchingTagEditHandler = async () => {
135-
let xmlConfiguration: WorkspaceConfiguration;
136-
if (window.activeTextEditor) {
137-
xmlConfiguration = workspace.getConfiguration('xml', window.activeTextEditor.document.uri);
138-
} else {
139-
xmlConfiguration = workspace.getConfiguration('xml');
140-
}
141-
const current = xmlConfiguration.mirrorCursorOnMatchingTag;
142-
await updateConfig(xmlConfiguration, 'mirrorCursorOnMatchingTag', !current);
143-
}
144-
145-
toDispose.push(commands.registerCommand(matchingTagEditCommand, matchingTagEditHandler));
146-
147117
if (extensions.onDidChange) {// Theia doesn't support this API yet
148118
extensions.onDidChange(() => {
149119
onExtensionChange(extensions.all);
150120
});
151121
}
122+
123+
disposable = activateTagClosing(tagProvider, { xml: true, xsl: true }, Commands.AUTO_CLOSE_TAGS);
124+
toDispose.push(disposable);
152125
});
153126
languages.setLanguageConfiguration('xml', getIndentationRules());
154127
languages.setLanguageConfiguration('xsl', getIndentationRules());
@@ -166,7 +139,7 @@ export function activate(context: ExtensionContext) {
166139
let configXML = workspace.getConfiguration().get('xml');
167140
let xml;
168141
if (!configXML) { //Set default preferences if not provided
169-
const defaultValue =
142+
const defaultValue =
170143
{
171144
xml: {
172145
trace: {
@@ -187,7 +160,7 @@ export function activate(context: ExtensionContext) {
187160
xml = defaultValue;
188161
} else {
189162
let x = JSON.stringify(configXML); //configXML is not a JSON type
190-
xml = { "xml": JSON.parse(x) };
163+
xml = { "xml" : JSON.parse(x)};
191164
}
192165
xml['xml']['logs']['file'] = logfile;
193166
xml['xml']['useCache'] = true;
@@ -198,7 +171,7 @@ export function activate(context: ExtensionContext) {
198171

199172
function getIndentationRules(): LanguageConfiguration {
200173
return {
201-
174+
202175
// indentationRules referenced from:
203176
// https://github.com/microsoft/vscode/blob/d00558037359acceea329e718036c19625f91a1a/extensions/html-language-features/client/src/htmlMain.ts#L114-L115
204177
indentationRules: {
@@ -219,24 +192,3 @@ function getIndentationRules(): LanguageConfiguration {
219192
};
220193
}
221194

222-
/**
223-
* Update config with the following precedence: WorkspaceFolder -> Workspace -> Global
224-
* @param config config containing the section to update
225-
* @param section section to update
226-
* @param value new value
227-
*/
228-
async function updateConfig(config: WorkspaceConfiguration, section: string, value: any): Promise<void> {
229-
try {
230-
await config.update(section, value);
231-
return;
232-
} catch(e) {
233-
// try ConfigurationTarget.Global
234-
}
235-
236-
try {
237-
await config.update(section, value, ConfigurationTarget.Global);
238-
return;
239-
} catch(e) {
240-
throw 'Failed to update config';
241-
}
242-
}

0 commit comments

Comments
 (0)