-
Notifications
You must be signed in to change notification settings - Fork 20
feat(windows): support displaying and opening .lnk shortcut files #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import log from 'electron-log' | |
| import iconv from 'iconv-lite' | ||
| import { LINE_ENDING_REG, LF_LINE_ENDING_REG, CRLF_LINE_ENDING_REG } from '../config' | ||
| import { isDirectory2 } from 'common/filesystem' | ||
| import { isMarkdownFile } from 'common/filesystem/paths' | ||
| import { isMarkdownFile, resolveShortcut } from 'common/filesystem/paths' | ||
| import { normalizeAndResolvePath, writeFile } from '../filesystem' | ||
| import { guessEncoding } from './encoding' | ||
|
|
||
|
|
@@ -87,7 +87,7 @@ export const loadMarkdownFile = async ( | |
| // TODO: Use streams to not buffer the file multiple times and only guess | ||
| // encoding on the first 256/512 bytes. | ||
|
|
||
| let buffer = await fsPromises.readFile(path.resolve(pathname)) | ||
| let buffer = await fsPromises.readFile(path.resolve(resolveShortcut(pathname))) | ||
|
||
|
|
||
| const encoding = guessEncoding(buffer, autoGuessEncoding) | ||
| const supported = iconv.encodingExists(encoding.encoding) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasMarkdownExtensionnow callsresolveShortcut(filename)on every invocation. On Windows this causesshell.readShortcutLinkto run for non-.lnkpaths as well (including simple names like "foo" from the renderer), which can be a hot path (watcher filtering, quick open, etc.) and may rely on exceptions for control flow. Consider makingresolveShortcuta no-op unless the path ends with.lnk(and ideally exists/is a file) so that normal markdown extension checks stay cheap.