Skip to content

Commit d80aa44

Browse files
committed
Fix #107
1 parent 6465729 commit d80aa44

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 0.3.1 | 2019-05-07
4+
5+
- Dispose selection sync after closing Polacode window so selection no longer jams clipboard. #107.
6+
37
### 0.3.0 | 2019-05-07
48

59
- Major rewrite. See features in [#105](https://github.com/octref/polacode/pull/105).

src/extension.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ function activate(context) {
2828
innerHTML: state.innerHTML,
2929
bgColor: context.globalState.get('polacode.bgColor', '#2e3440')
3030
})
31-
setupSelectionSync()
31+
const selectionListener = setupSelectionSync()
32+
panel.onDidDispose(() => {
33+
selectionListener.dispose()
34+
})
3235
setupMessageListeners()
3336
}
3437
})
@@ -41,6 +44,11 @@ function activate(context) {
4144

4245
panel.webview.html = getHtmlContent(htmlPath)
4346

47+
const selectionListener = setupSelectionSync()
48+
panel.onDidDispose(() => {
49+
selectionListener.dispose()
50+
})
51+
4452
setupMessageListeners()
4553

4654
const fontFamily = vscode.workspace.getConfiguration('editor').fontFamily
@@ -60,8 +68,6 @@ function activate(context) {
6068
}
6169
})
6270

63-
setupSelectionSync()
64-
6571
function setupMessageListeners() {
6672
panel.webview.onDidReceiveMessage(({ type, data }) => {
6773
switch (type) {
@@ -102,7 +108,7 @@ function activate(context) {
102108

103109
function syncSettings() {
104110
const settings = vscode.workspace.getConfiguration('polacode')
105-
const editorSettings = vscode.workspace.getConfiguration('editor')
111+
const editorSettings = vscode.workspace.getConfiguration('editor', null)
106112
panel.webview.postMessage({
107113
type: 'updateSettings',
108114
shadow: settings.get('shadow'),
@@ -114,7 +120,7 @@ function activate(context) {
114120
}
115121

116122
function setupSelectionSync() {
117-
vscode.window.onDidChangeTextEditorSelection(e => {
123+
return vscode.window.onDidChangeTextEditorSelection(e => {
118124
if (e.selections[0] && !e.selections[0].isEmpty) {
119125
vscode.commands.executeCommand('editor.action.clipboardCopyAction')
120126
panel.postMessage({

0 commit comments

Comments
 (0)