-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #852 from t9md/lazy-f
Better `f` as chimera of clever-f and vim-seek.
- Loading branch information
Showing
13 changed files
with
355 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const DecorationTypes = { | ||
"pre-confirm": { | ||
decorationProps: { | ||
type: "highlight", | ||
class: "vim-mode-plus-find-char pre-confirm", | ||
}, | ||
}, | ||
"post-confirm": { | ||
timeout: 2000, | ||
decorationProps: { | ||
type: "highlight", | ||
class: "vim-mode-plus-find-char post-confirm", | ||
}, | ||
}, | ||
"post-confirm-long": { | ||
timeout: 4000, | ||
decorationProps: { | ||
type: "highlight", | ||
class: "vim-mode-plus-find-char post-confirm-long", | ||
}, | ||
}, | ||
} | ||
|
||
module.exports = class HighlightFind { | ||
constructor(vimState) { | ||
this.vimState = vimState | ||
vimState.onDidDestroy(() => this.destroy()) | ||
|
||
const {editor} = vimState | ||
this.markerLayer = editor.addMarkerLayer() | ||
this.decorationLayer = editor.decorateMarkerLayer(this.markerLayer, {}) | ||
} | ||
|
||
destroy() { | ||
this.decorationLayer.destroy() | ||
this.markerLayer.destroy() | ||
} | ||
|
||
clearMarkers() { | ||
this.markerLayer.clear() | ||
} | ||
|
||
highlightRanges(ranges, decorationType) { | ||
if (this.clearMarkerTimeoutID) { | ||
clearTimeout(this.clearMarkerTimeoutID) | ||
this.clearMarkerTimeoutID = null | ||
} | ||
|
||
this.clearMarkers() | ||
// We need to force update here to restart(re-trigger) keyframe animation. | ||
this.vimState.editor.component.updateSync() | ||
|
||
for (const range of ranges) { | ||
this.markerLayer.markBufferRange(range) | ||
} | ||
|
||
const {timeout, decorationProps} = DecorationTypes[decorationType] | ||
this.decorationLayer.setProperties(decorationProps) | ||
if (timeout) { | ||
this.clearMarkerTimeoutID = setTimeout(() => this.clearMarkers(), timeout) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.