Skip to content

Commit

Permalink
Update 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gael-Lopes-Da-Silva committed Nov 2, 2024
1 parent 759380b commit 049c3c2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@

---

### 0.0.2
- Added a delay before highlight

### 0.0.1
- Initial release
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Spaced has 2 command available right now. `Spaced: Toggle Hightlight` that turn
"spaced.borderSize": 1, // Border size of the highlight
"spaced.borderColor": "#ff0000", // Border color of the highlight
"spaced.backgroundColor": "#ff000050", // Background color of the highlight
"spaced.delay": 900, // The time to wait before highlight is triggered
}
~~~

Expand Down
Binary file renamed build/spaced-0.0.1.vsix → build/spaced-0.0.2.vsix
Binary file not shown.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
"default": 1,
"description": "Whitespaces border size.",
"type": "integer"
},
"spaced.delay": {
"default": 900,
"description": "The time to wait before highlight is triggered.",
"type": "integer"
}
},
"title": "Spaced Configuration",
Expand Down Expand Up @@ -109,5 +114,5 @@
"package": "vsce package -o build",
"publish": "vsce publish"
},
"version": "0.0.1"
"version": "0.0.2"
}
16 changes: 12 additions & 4 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const vscode = require('vscode');

let decorationType = null;
let timeout = null;

let highlight = true;
let backgroundColor = "#ff000050";
Expand All @@ -13,6 +14,7 @@ let borderColor = "#ff0000";
let borderSize = 1;
let maxFileSize = 1000000;
let maxLineCount = 10000;
let delay = 900;

// ----------------------------------------------------

Expand Down Expand Up @@ -47,6 +49,7 @@ function loadConfiguration() {
borderSize = config.inspect('borderSize').globalValue || config.get('borderSize');
maxFileSize = config.inspect('maxFileSize').globalValue || config.get('maxFileSize');
maxLineCount = config.inspect('maxLineCount').globalValue || config.get('maxLineCount');
delay = config.inspect('delay').globalValue || config.get('delay');
}

function createDecorationType() {
Expand Down Expand Up @@ -74,10 +77,15 @@ function onDidChangeActiveTextEditor() {
}

function onDidChangeTextDocument(event) {
if (!vscode.window.activeTextEditor) return;
const activeTextEditor = vscode.window.activeTextEditor;
if (!activeTextEditor) return;

if (event.document === vscode.window.activeTextEditor.document) {
updateDecorations();
if (event.document === activeTextEditor.document) {
if (timeout) clearTimeout(timeout);

timeout = setTimeout(() => {
updateDecorations();
}, delay);
}
}

Expand Down Expand Up @@ -117,7 +125,7 @@ function updateDecorations() {

function clearDecorations() {
const activeTextEditor = vscode.window.activeTextEditor;
if (!activeTextEditor) return;
if (!activeTextEditor && !decorationType) return;

activeTextEditor.setDecorations(decorationType, []);
}
Expand Down

0 comments on commit 049c3c2

Please sign in to comment.