-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scaffold using floating content widgets
- Loading branch information
Showing
4 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/floatingReplacement.ts
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,39 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
|
||
import { Disposable } from '../../../../../../base/common/lifecycle.js'; | ||
import { IObservable } from '../../../../../../base/common/observable.js'; | ||
import { ContentWidgetPositionPreference } from '../../../../../browser/editorBrowser.js'; | ||
import { ObservableCodeEditor } from '../../../../../browser/observableCodeEditor.js'; | ||
import { SingleTextEdit } from '../../../../../common/core/textEdit.js'; | ||
import { n } from './utils.js'; | ||
import './view.css'; | ||
|
||
|
||
export class FloatingReplacement extends Disposable { | ||
static _widgetCounter = 0; | ||
|
||
private readonly _domNode = n.div({ | ||
class: 'floatingReplacement', | ||
}, [ | ||
this._edit.map(edit => edit.text) | ||
]).keepUpdated(this._store); | ||
|
||
constructor( | ||
private readonly _editorObs: ObservableCodeEditor, | ||
private readonly _edit: IObservable<SingleTextEdit>, | ||
) { | ||
super(); | ||
this._register(this._editorObs.createContentWidget({ | ||
domNode: this._domNode.element, | ||
position: this._edit.map(edit => ({ | ||
preference: [ContentWidgetPositionPreference.ABOVE], | ||
position: edit.range.getStartPosition() | ||
})), | ||
allowEditorOverflow: false | ||
})); | ||
} | ||
} |
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