Repository navigation
Writing to file off-screen so it displays upon open - #15
dwertheimer wants to merge 11 commits into
Conversation
Working around a bug/feature where the appendParagraph was not showing up in the Editor. It's better this way anyway, because I can ask the user whether to open it or not. :)
No functional changes. Just making the Linter happier
If item is a todo or list, etc. then don't delete it after using it for the title
jgclark
left a comment
There was a problem hiding this comment.
(I've now found how to check PRs without approving first.)
I've tried this, and I can't see an obvious problem, but it appears to be failing at line 282 newNote.appendParagraph(movedText, 'empty') for no obvious reason. I added some temporary logging and the movedText is OK, but it doesn't append anything, and code execution stops then.
Otherwise the only thing I can spot is that the .shift() is being done on a const array, though it doesn't seem to matter, for reasons which are beyond me.
|
I think shift() on a const array is ok because arrays in JS are all
mutable. To me that’s one of the confusing things about const with Objects
and Arrays. You can’t overwrite them entirely but you can edit the contents
(eg object properties) or array items at will.
In fact, the first example in the JS manual does exactly this:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
…On Sun, Jun 13 2021 at 2:55 PM, Jonathan Clark ***@***.***> wrote:
***@***.**** commented on this pull request.
(I've now found how to check PRs without approving first.)
I've tried this, and I can't see an obvious problem, but it appears to be
failing at line 282 newNote.appendParagraph(movedText, 'empty') for no
obvious reason. I added some temporary logging and the movedText is OK,
but it doesn't append anything, and code execution stops then.
Otherwise the only thing I can spot is that the .shift() is being done on
a const array, though it doesn't seem to matter, for reasons which are
beyond me.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACEI6VEAEF6F3JHSGYAUCATTSUSMJANCNFSM46TK4CBA>
.
|
Stuck on how to open a file that's in a folder. Pushing code so Jonathan can see it with the console logs.
Thanks -- a bit confusing, but good to know! |
testing projectNoteByFilename
Still not working
|
I'm really willing this on to work! However, for the record, first test of this (to a sub-folder) fails: Second try, to root, also fails: I'll now try and work on it myself. |
|
Sorry Jonathan. @eduard said he was going to look at the API today. My
code may be buggy, but the docs should be more clear on how “filename”s
work. Might be a good idea to use the parameter “path” to delineate from
“filename” in the appropriate APIs.
…On Mon, Jun 14 2021 at 1:45 PM, Jonathan Clark ***@***.***> wrote:
I'm really willing this on to work. However, first test of this (to a
sub-folder) fails:
newNoteFromSelection (running v0.9.2) 6 selected:
1st Para Type = text = "one"
currentFolder=TEST
origFile:TEST repeats
newNote returned Filename:TEST/one.md
About to open filename: "TEST/TEST/one.md" (no leading slash) using projectNoteByFilename
Didn't work! projectNoteByFilename returned undefined
About to open filename: "/TEST/TEST/one.md" (with leading slash) using projectNoteByFilename
Didn't work! projectNoteByFilename returned undefined
About to open filename: "TEST/TEST/one.md" (Jonathan way) using projectNoteByFilename
Didn't work! projectNoteByFilename returned undefined
About to open filename: "TEST/one.md" (no folder path, filename only) using projectNoteByFilename
Didn't work! projectNoteByFilename returned undefined
About to open filename: "TEST/TEST/one.md" (using noteByFilename Instead) using noteByFilename
Didn't work! noteByFilename returned undefined
About to open filename: "/TEST/TEST/one.md" (using noteByFilename Instead, leading slash) using noteByFilename
Didn't work! noteByFilename returned undefined
Could not open file: "/TEST/TEST/one.md"
newNoteFromSelection (finished)
Second try, to root, also fails:
newNoteFromSelection (running v0.9.2) 6 selected:
1st Para Type = text = "one"
currentFolder=/
origFile:TEST repeats
newNote returned Filename:one.md
About to open filename: "one.md" (no leading slash) using projectNoteByFilename
Didn't work! projectNoteByFilename returned undefined
About to open filename: "one.md" (with leading slash) using projectNoteByFilename
Didn't work! projectNoteByFilename returned undefined
About to open filename: "//one.md" (Jonathan way) using projectNoteByFilename
Didn't work! projectNoteByFilename returned undefined
About to open filename: "one.md" (no folder path, filename only) using projectNoteByFilename
Didn't work! projectNoteByFilename returned undefined
About to open filename: "one.md" (using noteByFilename Instead) using noteByFilename
Didn't work! noteByFilename returned undefined
About to open filename: "one.md" (using noteByFilename Instead, leading slash) using noteByFilename
Didn't work! noteByFilename returned undefined
Could not open file: "one.md"
newNoteFromSelection (finished)
I'll now try and work on it myself.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACEI6VCFG35GN4FMXCYQC3LTSZS5XANCNFSM46TK4CBA>
.
|
|
Hey this may be a clue in your output:
newNote returned Filename:TEST/one.md About to open filename:
"TEST/TEST/one.md"
I have never seen addNote return a directory-slash-filename (path). Is this
new? Why did this happen here and not for us before?
…On Mon, Jun 14 2021 at 2:36 PM, David Wertheimer ***@***.***> wrote:
Sorry Jonathan. @eduard said he was going to look at the API today. My
code may be buggy, but the docs should be more clear on how “filename”s
work. Might be a good idea to use the parameter “path” to delineate from
“filename” in the appropriate APIs.
On Mon, Jun 14 2021 at 1:45 PM, Jonathan Clark ***@***.***>
wrote:
> I'm really willing this on to work. However, first test of this (to a
> sub-folder) fails:
>
> newNoteFromSelection (running v0.9.2) 6 selected:
> 1st Para Type = text = "one"
> currentFolder=TEST
> origFile:TEST repeats
> newNote returned Filename:TEST/one.md
> About to open filename: "TEST/TEST/one.md" (no leading slash) using projectNoteByFilename
> Didn't work! projectNoteByFilename returned undefined
> About to open filename: "/TEST/TEST/one.md" (with leading slash) using projectNoteByFilename
> Didn't work! projectNoteByFilename returned undefined
> About to open filename: "TEST/TEST/one.md" (Jonathan way) using projectNoteByFilename
> Didn't work! projectNoteByFilename returned undefined
> About to open filename: "TEST/one.md" (no folder path, filename only) using projectNoteByFilename
> Didn't work! projectNoteByFilename returned undefined
> About to open filename: "TEST/TEST/one.md" (using noteByFilename Instead) using noteByFilename
> Didn't work! noteByFilename returned undefined
> About to open filename: "/TEST/TEST/one.md" (using noteByFilename Instead, leading slash) using noteByFilename
> Didn't work! noteByFilename returned undefined
> Could not open file: "/TEST/TEST/one.md"
>
> newNoteFromSelection (finished)
>
> Second try, to root, also fails:
>
> newNoteFromSelection (running v0.9.2) 6 selected:
> 1st Para Type = text = "one"
> currentFolder=/
> origFile:TEST repeats
> newNote returned Filename:one.md
> About to open filename: "one.md" (no leading slash) using projectNoteByFilename
> Didn't work! projectNoteByFilename returned undefined
> About to open filename: "one.md" (with leading slash) using projectNoteByFilename
> Didn't work! projectNoteByFilename returned undefined
> About to open filename: "//one.md" (Jonathan way) using projectNoteByFilename
> Didn't work! projectNoteByFilename returned undefined
> About to open filename: "one.md" (no folder path, filename only) using projectNoteByFilename
> Didn't work! projectNoteByFilename returned undefined
> About to open filename: "one.md" (using noteByFilename Instead) using noteByFilename
> Didn't work! noteByFilename returned undefined
> About to open filename: "one.md" (using noteByFilename Instead, leading slash) using noteByFilename
> Didn't work! noteByFilename returned undefined
> Could not open file: "one.md"
>
> newNoteFromSelection (finished)
>
> I'll now try and work on it myself.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#15 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ACEI6VCFG35GN4FMXCYQC3LTSZS5XANCNFSM46TK4CBA>
> .
>
|
|
Have just mentioned it on Discord. There was a bug where the notes which
were created inside a folder with `newNote` weren't cached immediately. So
the returned filename couldn't be used to query the note unless you had an
await CommandBar user input in between. Will be fixed in the next beta.
@david, you are right about the confusion with the filename. Actually, it
should have been a relative path all along. So yes, since the last Beta
update `newNote` returns the relative path. I have updated the API
documentation to point out that the relative folder is included in returns
and must be in function variables.
…On Mon, Jun 14, 2021 at 4:40 PM David Wertheimer ***@***.***> wrote:
Hey this may be a clue in your output:
newNote returned Filename:TEST/one.md About to open filename:
"TEST/TEST/one.md"
I have never seen addNote return a directory-slash-filename (path). Is
this new? Why did this happen here and not for us before?
On Mon, Jun 14 2021 at 2:36 PM, David Wertheimer ***@***.***>
wrote:
> Sorry Jonathan. @eduard said he was going to look at the API today. My
> code may be buggy, but the docs should be more clear on how “filename”s
> work. Might be a good idea to use the parameter “path” to delineate from
> “filename” in the appropriate APIs.
>
>
> On Mon, Jun 14 2021 at 1:45 PM, Jonathan Clark ***@***.***>
> wrote:
>
>> I'm really willing this on to work. However, first test of this (to a
>> sub-folder) fails:
>>
>> newNoteFromSelection (running v0.9.2) 6 selected:
>> 1st Para Type = text = "one"
>> currentFolder=TEST
>> origFile:TEST repeats
>> newNote returned Filename:TEST/one.md
>> About to open filename: "TEST/TEST/one.md" (no leading slash) using projectNoteByFilename
>> Didn't work! projectNoteByFilename returned undefined
>> About to open filename: "/TEST/TEST/one.md" (with leading slash) using projectNoteByFilename
>> Didn't work! projectNoteByFilename returned undefined
>> About to open filename: "TEST/TEST/one.md" (Jonathan way) using projectNoteByFilename
>> Didn't work! projectNoteByFilename returned undefined
>> About to open filename: "TEST/one.md" (no folder path, filename only) using projectNoteByFilename
>> Didn't work! projectNoteByFilename returned undefined
>> About to open filename: "TEST/TEST/one.md" (using noteByFilename Instead) using noteByFilename
>> Didn't work! noteByFilename returned undefined
>> About to open filename: "/TEST/TEST/one.md" (using noteByFilename Instead, leading slash) using noteByFilename
>> Didn't work! noteByFilename returned undefined
>> Could not open file: "/TEST/TEST/one.md"
>>
>> newNoteFromSelection (finished)
>>
>> Second try, to root, also fails:
>>
>> newNoteFromSelection (running v0.9.2) 6 selected:
>> 1st Para Type = text = "one"
>> currentFolder=/
>> origFile:TEST repeats
>> newNote returned Filename:one.md
>> About to open filename: "one.md" (no leading slash) using projectNoteByFilename
>> Didn't work! projectNoteByFilename returned undefined
>> About to open filename: "one.md" (with leading slash) using projectNoteByFilename
>> Didn't work! projectNoteByFilename returned undefined
>> About to open filename: "//one.md" (Jonathan way) using projectNoteByFilename
>> Didn't work! projectNoteByFilename returned undefined
>> About to open filename: "one.md" (no folder path, filename only) using projectNoteByFilename
>> Didn't work! projectNoteByFilename returned undefined
>> About to open filename: "one.md" (using noteByFilename Instead) using noteByFilename
>> Didn't work! noteByFilename returned undefined
>> About to open filename: "one.md" (using noteByFilename Instead, leading slash) using noteByFilename
>> Didn't work! noteByFilename returned undefined
>> Could not open file: "one.md"
>>
>> newNoteFromSelection (finished)
>>
>> I'll now try and work on it myself.
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub
>> <#15 (comment)>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/ACEI6VCFG35GN4FMXCYQC3LTSZS5XANCNFSM46TK4CBA>
>> .
>>
>
|
Moved question in the middle as a work-around so it should work on / and folder use cases. @jgclark pls let me know if you find anything else
|
Closing PR because moving code to Filer |
Working around a bug/feature where the appendParagraph was not showing up in the Editor. It's better this way anyway, because I can ask the user whether to open it or not. :)
@jgclark pls let me know if this works better for you