Skip to content

Commit

Permalink
Showing matching bracket immediately since it’s fast (closes #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Dec 27, 2017
1 parent 0bbb2bb commit 410db8f
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function activate(context: vscode.ExtensionContext) {

vscode.window.onDidChangeTextEditorSelection(event => {
if (event.textEditor === vscode.window.activeTextEditor && is_clojure(event.textEditor))
scheduleMatchPairs();
matchPairs();
}, null, context.subscriptions);

vscode.workspace.onDidChangeTextDocument(event => {
Expand Down Expand Up @@ -87,7 +87,7 @@ export function activate(context: vscode.ExtensionContext) {
if (!!matchedType)
activeEditor.setDecorations(matchedType, []);
matchedBracketStyle = configuration.get("matchedBracketStyle");
matchedType = vscode.window.createTextEditorDecorationType(matchedBracketStyle || {light: {backgroundColor: "#E0E0E0"}, dark: {backgroundColor: "#444"}});
matchedType = vscode.window.createTextEditorDecorationType(matchedBracketStyle || {light: {backgroundColor: "#d0d0d0"}, dark: {backgroundColor: "#444"}});
dirty = true;
}

Expand All @@ -99,19 +99,10 @@ export function activate(context: vscode.ExtensionContext) {
function scheduleRainbowBrackets() {
if (rainbowTimer)
clearTimeout(rainbowTimer);
if (matchTimer) // because updateRainbowBrackets triggers matchPairs
clearTimeout(matchTimer);
if (is_clojure(activeEditor))
rainbowTimer = setTimeout(updateRainbowBrackets, 16);
}

function scheduleMatchPairs() {
if (matchTimer)
clearTimeout(matchTimer);
if (is_clojure(activeEditor))
matchTimer = setTimeout(matchPairs, 16);
}

function updateRainbowBrackets() {
if (!is_clojure(activeEditor)) return;

Expand Down

0 comments on commit 410db8f

Please sign in to comment.