Start work on respecting project-specific settings
This commit is contained in:
parent
e4530471de
commit
89446c7fd4
16 changed files with 326 additions and 83 deletions
|
@ -216,6 +216,11 @@ pub trait File: Send + Sync {
|
|||
/// of its worktree, then this method will return the name of the worktree itself.
|
||||
fn file_name<'a>(&'a self, cx: &'a AppContext) -> &'a OsStr;
|
||||
|
||||
/// Returns the id of the worktree to which this file belongs.
|
||||
///
|
||||
/// This is needed for looking up project-specific settings.
|
||||
fn worktree_id(&self) -> usize;
|
||||
|
||||
fn is_deleted(&self) -> bool;
|
||||
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
@ -1803,7 +1808,11 @@ impl BufferSnapshot {
|
|||
|
||||
pub fn language_indent_size_at<T: ToOffset>(&self, position: T, cx: &AppContext) -> IndentSize {
|
||||
let language_name = self.language_at(position).map(|language| language.name());
|
||||
let settings = language_settings(language_name.as_deref(), cx);
|
||||
let settings = language_settings(
|
||||
language_name.as_deref(),
|
||||
self.file().map(|f| f.as_ref()),
|
||||
cx,
|
||||
);
|
||||
if settings.hard_tabs {
|
||||
IndentSize::tab()
|
||||
} else {
|
||||
|
@ -2128,7 +2137,11 @@ impl BufferSnapshot {
|
|||
cx: &'a AppContext,
|
||||
) -> &'a LanguageSettings {
|
||||
let language = self.language_at(position);
|
||||
language_settings(language.map(|l| l.name()).as_deref(), cx)
|
||||
language_settings(
|
||||
language.map(|l| l.name()).as_deref(),
|
||||
self.file.as_ref().map(AsRef::as_ref),
|
||||
cx,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn language_scope_at<D: ToOffset>(&self, position: D) -> Option<LanguageScope> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue