Skip to content

Commit

Permalink
fix: 🐛 Fix #8: 'm' flag
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Oct 24, 2021
1 parent 5328b64 commit e813997
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
45 changes: 26 additions & 19 deletions main.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Components/AddQComponent.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
import { Notice } from "obsidian";
import { App, Notice } from "obsidian";
import type { Query } from "src/interfaces";
import type ACPlugin from "src/main";
import type { ACSettingTab, AddQModal } from "src/SettingTab";
import { cmdNextId, cmdRunId } from "src/utils";
import { onMount } from "svelte";
// export let app: App;
export let app: App;
export let plugin: ACPlugin;
export let modal: AddQModal;
export let settingsTab: ACSettingTab;
Expand Down Expand Up @@ -47,8 +47,8 @@
if (i > -1) {
// Remove old command
this.app.commands.removeCommand(cmdRunId(oldQ));
this.app.commands.removeCommand(cmdNextId(oldQ));
app.commands.removeCommand(cmdRunId(oldQ));
app.commands.removeCommand(cmdNextId(oldQ));
// Overwrite old Q
plugin.settings.savedQueries[i] = newQ;
Expand Down
2 changes: 1 addition & 1 deletion src/SettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class ACSettingTab extends PluginSettingTab {
},
(but) => {
but.addEventListener("click", () => {
console.log("editing" + i);
this.editSavedQ(i);
});
}
Expand Down Expand Up @@ -142,6 +141,7 @@ export class AddQModal extends Modal {
new AddQComponent({
target: contentEl,
props: {
app: this.app,
plugin: this.plugin,
modal: this,
settingsTab: this.settingsTab,
Expand Down
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ export default class ACPlugin extends Plugin {

const regex = createRegex(existingQ);
const matches = [...content.matchAll(regex)];
console.log({ matches });
nextI = matches.find((match) => match.index >= offset)?.index;
console.log({ matches, nextI });

// nextI = content.indexOf(existingQ.query, offset);
} else {
Expand All @@ -225,7 +225,11 @@ export default class ACPlugin extends Plugin {
to: editorSelection.head,
});
} else {
const loopedI = content.indexOf(toSelect);
const regex = createRegex(existingQ);
const matches = [...content.matchAll(regex)];
const loopedI = matches[0].index;
console.log({ matches, loopedI });

if (loopedI > -1) {
const editorSelection = this.createSelection(editor, loopedI, toSelect);
this.setSelections(appendQ, editor, editorSelection);
Expand Down

0 comments on commit e813997

Please sign in to comment.