-
-
Notifications
You must be signed in to change notification settings - Fork 91
Fix for markdown cells #2739
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
Fix for markdown cells #2739
Changes from 1 commit
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
languageId: markdown | ||
command: | ||
version: 7 | ||
spokenForm: change cell | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: notebookCell} | ||
usePrePhraseSnapshot: false | ||
initialState: | ||
documentContents: | | ||
``` | ||
code | ||
``` | ||
selections: | ||
- anchor: {line: 1, character: 0} | ||
active: {line: 1, character: 0} | ||
marks: {} | ||
finalState: | ||
documentContents: |+ | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,35 +9,46 @@ import { | |
import type { LanguageDefinitions } from "../../../languages/LanguageDefinitions"; | ||
import { ide } from "../../../singletons/ide.singleton"; | ||
import { NotebookCellTarget } from "../../targets"; | ||
import { BaseScopeHandler } from "./BaseScopeHandler"; | ||
import type { TargetScope } from "./scope.types"; | ||
import type { | ||
ComplexScopeType, | ||
ScopeHandler, | ||
ScopeIteratorRequirements, | ||
} from "./scopeHandler.types"; | ||
|
||
export class NotebookCellScopeHandler implements ScopeHandler { | ||
export class NotebookCellScopeHandler extends BaseScopeHandler { | ||
phillco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public readonly scopeType = { type: "notebookCell" } as const; | ||
public readonly iterationScopeType = { type: "document" } as const; | ||
public readonly includeAdjacentInEvery = false; | ||
protected isHierarchical = false; | ||
private readonly languageScopeHandler: ScopeHandler | undefined; | ||
|
||
constructor( | ||
private languageDefinitions: LanguageDefinitions, | ||
languageDefinitions: LanguageDefinitions, | ||
_scopeType: ScopeType, | ||
private languageId: string, | ||
) {} | ||
) { | ||
super(); | ||
|
||
this.languageScopeHandler = languageDefinitions | ||
.get(this.languageId) | ||
?.getScopeHandler(this.scopeType); | ||
} | ||
|
||
*generateScopes( | ||
get iterationScopeType(): ScopeType | ComplexScopeType { | ||
if (this.languageScopeHandler != null) { | ||
return this.languageScopeHandler.iterationScopeType; | ||
} | ||
return { type: "document" }; | ||
} | ||
|
||
*generateScopeCandidates( | ||
editor: TextEditor, | ||
position: Position, | ||
direction: Direction, | ||
hints: ScopeIteratorRequirements, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NTS: The actual type of the interface is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We needed something like what the base class does:
Rather than copying the logic it was easier to just rewrite this class to use the base class, which Andreas says should have been done originally, just didn't think of it |
||
): Iterable<TargetScope> { | ||
const scopeHandler = this.languageDefinitions | ||
.get(this.languageId) | ||
?.getScopeHandler(this.scopeType); | ||
|
||
if (scopeHandler != null) { | ||
yield* scopeHandler.generateScopeCandidates( | ||
if (this.languageScopeHandler != null) { | ||
yield* this.languageScopeHandler.generateScopes( | ||
editor, | ||
position, | ||
direction, | ||
|
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.
NB:
notebookCell
just means the "cell" scope type. It doesn't actually mean a notebook cell (and in fact here it means a markdown table cell), but we added notebooks first and we don't want to rename it.