-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.js
49 lines (35 loc) · 1.36 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const vscode = require('vscode');
const REPLACE = String.fromCharCode(173);
function activate(context) {
console.log('Congratulations, your extension "indesigncleanup" is now active!');
let disposable = vscode.commands.registerCommand('extension.blickIndesignCleanup', function () {
let editor = vscode.window.activeTextEditor;
if (!editor) {
return; // No open text editor
}
let ranges = [];
let index = editor.document.getText().indexOf(REPLACE);
while(index >= 0)
{
console.log(index);
let positionStart = editor.document.positionAt(index);
let positionEnd = new vscode.Position(positionStart.line, positionStart.character + 1);
let range = new vscode.Range(positionStart, positionEnd)
ranges.push(range);
index = editor.document.getText().indexOf(REPLACE, index + 1);
}
editor.edit(function(editBuilder) {
for(var i = 0; i < ranges.length; i++)
{
editBuilder.replace(ranges[i], '');
}
});
console.log("Fertig");
vscode.window.showInformationMessage(ranges.length + ' Hyphens replaced :)');
});
context.subscriptions.push(disposable);
}
exports.activate = activate;
function deactivate() {
}
exports.deactivate = deactivate;