Skip to content

Commit 738553d

Browse files
committed
Make ocurrence highlight delay configurable
1 parent 665e045 commit 738553d

5 files changed

Lines changed: 27 additions & 13 deletions

File tree

dist/main/atom/occurrence/controller.js

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/atom/occurrence/controller.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main/atom/occurrence/controller.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {CompositeDisposable, DisplayMarker, TextEditor} from "atom"
2-
import {debounce} from "lodash"
2+
import {debounce, DebouncedFunc} from "lodash"
33
import {DocumentHighlightsItem} from "typescript/lib/protocol"
44
import {GetClientFunction} from "../../../client"
55
import {handlePromise} from "../../../utils"
@@ -11,13 +11,16 @@ export class OccurenceController {
1111
private disposed = false
1212

1313
constructor(private getClient: GetClientFunction, private editor: TextEditor) {
14-
const debouncedUpdate = debounce(() => {
15-
handlePromise(this.update())
16-
}, 100)
14+
let debouncedUpdate: DebouncedFunc<() => void>
1715
this.disposables.add(
18-
editor.onDidChangeCursorPosition(debouncedUpdate),
19-
editor.onDidChangePath(debouncedUpdate),
20-
editor.onDidChangeGrammar(debouncedUpdate),
16+
atom.config.observe("atom-typescript.ocurrenceHighlightDebounceTimeout", (val) => {
17+
debouncedUpdate = debounce(() => {
18+
handlePromise(this.update())
19+
}, val)
20+
}),
21+
editor.onDidChangeCursorPosition(() => debouncedUpdate()),
22+
editor.onDidChangePath(() => debouncedUpdate()),
23+
editor.onDidChangeGrammar(() => debouncedUpdate()),
2124
)
2225
}
2326

lib/typings/atom-config.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ declare module "atom" {
1313
"atom-typescript.disableAtomIdeDefinitions": boolean
1414
"atom-typescript.buildStatusTimeout": number
1515
"atom-typescript.getErrDebounceTimeout": number
16+
"atom-typescript.ocurrenceHighlightDebounceTimeout": number
1617
"atom-typescript.showSemanticView": boolean
1718
"atom-typescript.tooltipDelay": number
1819
"atom-typescript.tooltipPosition": "top" | "bottom"
@@ -43,6 +44,7 @@ declare module "atom" {
4344
disableAtomIdeDefinitions: boolean
4445
buildStatusTimeout: number
4546
getErrDebounceTimeout: number
47+
ocurrenceHighlightDebounceTimeout: number
4648
showSemanticView: boolean
4749
tooltipDelay: number
4850
tooltipPosition: "top" | "bottom"

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,18 @@
9898
},
9999
"getErrDebounceTimeout": {
100100
"title": "getErr Debounce Timeout",
101-
"description": "During on-change check, how long to wait for new changes until checking for errors",
101+
"description": "During on-change check, how long to wait for new changes until checking for errors, in ms",
102102
"type": "number",
103103
"default": "150",
104104
"order": 65
105105
},
106+
"ocurrenceHighlightDebounceTimeout": {
107+
"title": "Ocurrence Highlight Debounce Timeout",
108+
"description": "How long to wait before showing ocurrence highlights, in ms; low values may cause slowdowns on large projects",
109+
"type": "number",
110+
"default": "300",
111+
"order": 66
112+
},
106113
"showSemanticView": {
107114
"title": "Show semantic view",
108115
"description": "Show semantic view (outline) for typescript content",

0 commit comments

Comments
 (0)