Skip to content

Commit

Permalink
feat: ✨ Regex flags on cursorModal
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Oct 25, 2021
1 parent 576cfcf commit 25a2403
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 65 deletions.
124 changes: 78 additions & 46 deletions main.js

Large diffs are not rendered by default.

33 changes: 14 additions & 19 deletions src/Components/QueryModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,55 @@
export let modal: CursorsModal;
export let plugin: ACPlugin;
let inputEl: HTMLInputElement;
let queryEl: HTMLInputElement;
let flagsEl: HTMLInputElement;
let regexQEl: HTMLInputElement;
onMount(() => inputEl.focus());
onMount(() => queryEl.focus());
</script>

<div class="inputEls">
<input bind:this={inputEl} type="text" placeholder="Search Query" />
<input bind:this={queryEl} type="text" placeholder="Search Query" />
<button
on:click={() => {
const query = inputEl.value;
const q = { name: "", query, flags: "", regexQ: regexQEl.checked };
const q = {
name: "",
query: queryEl.value,
flags: flagsEl.value,
regexQ: regexQEl.checked,
};
const { selection, offset } = modal.getSelectionAndOffset();
modal.submit(q, selection, offset);
}}>Submit</button
>

<input bind:this={flagsEl} type="text" placeholder="Regex flags" width="10" />
<input bind:this={regexQEl} type="checkbox" name="regexQ" checked />
<label for="regexQ">Regex</label>
</div>

<div class="savedQs">
<ol>
{#each plugin.settings.savedQueries as savedQ}
{#each plugin.settings.savedQueries as q}
<li class="savedQ">
<span
class="savedQ-name"
on:click={(e) => {
// @ts-ignore
const name = e.target.textContent;
const q = plugin.settings.savedQueries.find(
(savedQ) => savedQ.name === name
);

const { selection, offset } = modal.getSelectionAndOffset();
modal.submit(q, selection, offset);
}}
>
{savedQ.name}
{q.name}
</span>
<span>→</span>
<span
class="savedQ-query"
on:click={(e) => {
// @ts-ignore
const query = e.target.textContent;
const q = plugin.settings.savedQueries.find(
(savedQ) => savedQ.query === query
);
const { selection, offset } = modal.getSelectionAndOffset();
modal.submit(q, selection, offset);
}}
>
{savedQ.query}
/{q.query}/{q.flags}
</span>
</li>
{/each}
Expand Down

0 comments on commit 25a2403

Please sign in to comment.