-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use uuids instead of file names and line numbers
- Loading branch information
1 parent
9d27101
commit c1fcdac
Showing
12 changed files
with
4,178 additions
and
2,197 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
{ | ||
"command.addNote.title": "Add note at current position", | ||
"command.openNote.title": "Open notes at current position", | ||
"command.removeNote.title": "Remove the note at current position", | ||
"configuration.lineColor.description": "Background color of line with notes (name or HEX)", | ||
"configuration.rulerColor.description": "Color of the ruler with notes (name or HEX)", | ||
"configuration.automaticallyDelete.description": "If it set to true, notes that do not correspond to files are automatically deleted.", | ||
"configuration.showGutterIcon.description": "If it set to true, displays the icon on the line where the note exists.", | ||
"configuration.gutterIconPath.description": "File path of the icon to be displayed" | ||
"command.addNote.title": "Line Note: Add note at current position", | ||
"command.openNote.title": "Line Note: Edit note at current position", | ||
"command.revealLine.title": "Line Note: Reveal line in notated file", | ||
"command.removeNote.title": "Line Note: Remove note at current position", | ||
"configuration.cleanUpOrphanedNotesInterval.description": "Interval at which to clean up unused notes in the background in ms. Only applies if cleanupOprhanedNotes is set to 'on-interval' or 'on-save-and-on-interval'. Default: 60000 (60s). For performance, a large value is recommended. In order to determine if a note has a corresponding marker, the entire project directory must be scanned.", | ||
"configuration.cleanUpOrphanedNotes.description": "Whether to cleanup orphaned notes on save file, on change file, on an interval, or never. Default: 'on-save'. Warning: On change file will provide more realtime updates but may affect performance and will delete note files instantly if not found in the changed file. Requires reload.", | ||
"configuration.includePaths.description": "File pattern globs to scan for note markers. Unmatched directories will be ignored.", | ||
"configuration.gutterIconPath.description": "File path of the icon to be displayed", | ||
"configuration.lineColor.description": "Background color of line with notes (name, HEX, or RGB)", | ||
"configuration.rulerColor.description": "Color of the ruler with notes (name, HEX, or RGB)", | ||
"configuration.showGutterIcon.description": "If it set to true, displays the icon on the line where the note exists. Default true." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { DocumentLink, DocumentLinkProvider, Position, ProviderResult, Range, TextDocument, Uri } from "vscode"; | ||
import { Note } from "./note"; | ||
import { getNotePrefix } from "./util"; | ||
|
||
export const editText = '[Edit]'; | ||
export const removeText = '[Remove]'; | ||
export class NoteLinkProvider implements DocumentLinkProvider { | ||
provideDocumentLinks(document: TextDocument): ProviderResult<DocumentLink[]> { | ||
const links: DocumentLink[] = []; | ||
const text = document.getText(); | ||
const uuids = Note.matchUuids(text); | ||
for (const uuid of uuids) { | ||
const lineIndex = Note.getLine(document, uuid); | ||
const line = document.lineAt(lineIndex); | ||
const editIndex = line.text.indexOf(editText); | ||
const editPosition = new Position(line.lineNumber, editIndex); | ||
const editEndPosition = new Position(line.lineNumber, editIndex + editText.length); | ||
const editRange = new Range(editPosition, editEndPosition); | ||
const editUri = Uri.parse( | ||
`command:linenote.openNote?${encodeURIComponent( | ||
JSON.stringify(uuid) | ||
)}` | ||
); | ||
const removeIndex = line.text.indexOf(removeText); | ||
const removePosition = new Position(line.lineNumber, removeIndex); | ||
const removeEndPosition = new Position(line.lineNumber, removeIndex + removeText.length); | ||
const removeRange = new Range(removePosition, removeEndPosition); | ||
const removeUri = Uri.parse( | ||
`command:linenote.removeNote?${encodeURIComponent( | ||
JSON.stringify(uuid) | ||
)}` | ||
); | ||
const openPosition = new Position(line.lineNumber, line.text.indexOf(getNotePrefix())); | ||
const openEndPosition = new Position(line.lineNumber, editIndex - 1); | ||
const openRange = new Range(openPosition, openEndPosition); | ||
const openLink = new DocumentLink(openRange, editUri); | ||
const editLink = new DocumentLink(editRange, editUri); | ||
const removeLink = new DocumentLink(removeRange, removeUri); | ||
links.push(openLink, editLink, removeLink); | ||
} | ||
|
||
return new Promise((res) => res(links)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as vscode from 'vscode'; | ||
import { getEditor } from './editorUtil'; | ||
|
||
|
||
export const formatIndentation = async () => { | ||
const editor = getEditor() | ||
|
||
const cursorPosition = editor.selection.anchor; | ||
const currentPosition = cursorPosition.line; | ||
|
||
// Get the text of the subsequent line | ||
const subsequentLine = editor.document.lineAt(currentPosition + 1); | ||
|
||
// Update the indentation of the current line to match the subsequent line | ||
await editor.edit(editBuilder => { | ||
const indentation = subsequentLine.firstNonWhitespaceCharacterIndex; | ||
const position = new vscode.Position(currentPosition, 0); | ||
editBuilder.insert(position, subsequentLine.text.substring(0, indentation)); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.