Skip to content

Writing to file off-screen so it displays upon open - #15

Closed
dwertheimer wants to merge 11 commits into
NotePlan:mainfrom
dwertheimer:dwertheimer-noteHelpers-nns
Closed

dwertheimer wants to merge 11 commits into
NotePlan:mainfrom
dwertheimer:dwertheimer-noteHelpers-nns

Conversation

@dwertheimer

@dwertheimer dwertheimer commented Jun 13, 2021 •

Copy link
Copy Markdown
Collaborator

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

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 jgclark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(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.

@dwertheimer

dwertheimer commented Jun 14, 2021 via email

Copy link
Copy Markdown
Collaborator Author

Stuck on how to open a file that's in a folder. Pushing code so Jonathan can see it with the console logs.
@jgclark

jgclark commented Jun 14, 2021

Copy link
Copy Markdown
Collaborator

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.

Thanks -- a bit confusing, but good to know!

@jgclark

jgclark commented Jun 14, 2021 •

Copy link
Copy Markdown
Collaborator

I'm really willing this on to work! However, for the record, 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.

@dwertheimer

dwertheimer commented Jun 14, 2021 via email

Copy link
Copy Markdown
Collaborator Author

@dwertheimer

dwertheimer commented Jun 14, 2021 via email

Copy link
Copy Markdown
Collaborator Author

@dwertheimer

dwertheimer commented Jun 14, 2021 via email

Copy link
Copy Markdown
Collaborator Author

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
@dwertheimer
dwertheimer requested a review from jgclark June 15, 2021 06:52
@dwertheimer

Copy link
Copy Markdown
Collaborator Author

Closing PR because moving code to Filer

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