Skip to content
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

feat: [lean4web] add option to change selectionMoveMove #508

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vscode-lean4/src/abbreviation/AbbreviationFeature.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbbreviationProvider } from '@leanprover/unicode-input'
import { AbbreviationProvider, SelectionMoveMode } from '@leanprover/unicode-input'
import { Disposable, OutputChannel, languages } from 'vscode'
import { AbbreviationHoverProvider } from './AbbreviationHoverProvider'
import { AbbreviationRewriterFeature } from './AbbreviationRewriterFeature'
Expand All @@ -8,7 +8,7 @@ export class AbbreviationFeature {
private readonly disposables = new Array<Disposable>()
readonly abbreviations: AbbreviationProvider

constructor(outputChannel: OutputChannel) {
constructor(outputChannel: OutputChannel, selectionMoveMove?: SelectionMoveMode) {
const config = new VSCodeAbbreviationConfig()
this.disposables.push(config)
this.abbreviations = new AbbreviationProvider(config)
Expand All @@ -18,7 +18,7 @@ export class AbbreviationFeature {
config.languages,
new AbbreviationHoverProvider(config, this.abbreviations),
),
new AbbreviationRewriterFeature(config, this.abbreviations, outputChannel),
new AbbreviationRewriterFeature(config, this.abbreviations, outputChannel, selectionMoveMove),
)
}

Expand Down
7 changes: 5 additions & 2 deletions vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AbbreviationProvider } from '@leanprover/unicode-input'
import { commands, Disposable, languages, OutputChannel, TextEditor, window, workspace } from 'vscode'
import { AbbreviationProvider, SelectionMoveMode } from '@leanprover/unicode-input'
import { Disposable, OutputChannel, TextEditor, commands, languages, window, workspace } from 'vscode'
import { extUriEquals, toExtUri } from '../utils/exturi'
import { VSCodeAbbreviationConfig } from './VSCodeAbbreviationConfig'
import { VSCodeAbbreviationRewriter } from './VSCodeAbbreviationRewriter'
Expand All @@ -17,6 +17,7 @@ export class AbbreviationRewriterFeature {
private readonly config: VSCodeAbbreviationConfig,
private readonly abbreviationProvider: AbbreviationProvider,
private readonly outputChannel: OutputChannel,
private readonly selectionMoveMove?: SelectionMoveMode,
) {
void this.changedActiveTextEditor(window.activeTextEditor)

Expand Down Expand Up @@ -49,6 +50,7 @@ export class AbbreviationRewriterFeature {
abbreviationProvider,
outputChannel,
window.activeTextEditor,
this.selectionMoveMove,
)
} else if (
this.activeAbbreviationRewriter !== undefined &&
Expand Down Expand Up @@ -86,6 +88,7 @@ export class AbbreviationRewriterFeature {
this.abbreviationProvider,
this.outputChannel,
activeTextEditor,
this.selectionMoveMove,
)
}

Expand Down
8 changes: 7 additions & 1 deletion vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class VSCodeAbbreviationRewriter implements AbbreviationTextSource {
readonly abbreviationProvider: AbbreviationProvider,
private readonly outputChannel: OutputChannel,
private readonly textEditor: TextEditor,
private selectionMoveMoveOverride?: SelectionMoveMode,
) {
this.rewriter = new AbbreviationRewriter(config, abbreviationProvider, this)

Expand Down Expand Up @@ -89,7 +90,12 @@ export class VSCodeAbbreviationRewriter implements AbbreviationTextSource {
}

selectionMoveMode(): SelectionMoveMode {
return { kind: 'OnlyMoveCursorSelections', updateUnchangedSelections: this.isVimExtensionInstalled }
return (
this.selectionMoveMoveOverride ?? {
kind: 'OnlyMoveCursorSelections',
updateUnchangedSelections: this.isVimExtensionInstalled,
}
)
}

collectSelections(): Range[] {
Expand Down
Loading