Skip to content

Conversation

@dongwook-chan
Copy link
Contributor

@dongwook-chan dongwook-chan commented Oct 24, 2024

Chrome Vimium destroys all markers if the current key matches with no current marker characters
Given following circumstances, for example,

markers = ['ab', 'ac', 'ad']
input = 'a'

if the current event.key is 'e' which does not match with any of the current marker characters ('b', 'c', 'd'),
the marker should disappear and also be disabled.

Unfortunately, existing code in obsidian vimium does make the markers disappear but not disable them.
This leads to an issue where no keyboard input works at all, that is, disabling any [a-zA-Z] keyboard inputs due to event.preventDefault();.

This PR aims to mitigate this issue and align with Chrome Vimium.
This PR checks if the current event.key matches with any of currenct marker characters and if so, marker is not only destroyed but also disabled.

dongwook-chan and others added 2 commits October 24, 2024 21:49
…r characters

- Chrome Vimium destorys all markers if the current key matches with no current marker characters
- This commit implements this feature

export function isMarkerMatchAt(key: string, markers: MarkerData[], index: number): boolean {
for (const marker of markers) {
if (key === marker.text[index]) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use startsWith instead of this.

So we use if (marker.text.startsWith(key)) {. This would remove index from the arguments.

Copy link
Contributor Author

@dongwook-chan dongwook-chan Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Just to clarify, did you mean if (marker.text.startsWith(input)) instead?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think you pass input from the plugin into the key field, when you call the isMarkerMatchAt function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants